User32Util.MessageLoopThread (JNA API)

com.sun.jna.platform.win32

## Class User32Util.MessageLoopThread

- java.lang.Object
- - java.lang.Thread
  - - com.sun.jna.platform.win32.User32Util.MessageLoopThread

- All Implemented Interfaces:
    java.lang.Runnable
  Enclosing class:
    User32Util

      public static class User32Util.MessageLoopThread
      extends java.lang.Thread

  Helper class, that runs a windows message loop as a seperate thread. This is intended to be used in conjunction with APIs, that need a spinning message loop. One example for this are the DDE functions, that can only be used if a message loop is present. To enable interaction with the mainloop the MessageLoopThread allows to dispatch callables into the mainloop and let these Callables be invoked on the message thread. This implies, that the Callables should block the loop as short as possible.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `User32Util.MessageLoopThread.Handler`

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `User32Util.MessageLoopThread()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `exit()`
    `protected boolean` | `getMessageFailed()` The method is called from the thread, that run the message dispatcher, when the call to `User32.GetMessage(com.sun.jna.platform.win32.WinUser.MSG, com.sun.jna.platform.win32.WinDef.HWND, int, int)` fails (returns `-1`).
    `void` | `run()`
    `<V> java.util.concurrent.Future<V>` | `runAsync(java.util.concurrent.Callable<V> command)`
    `<V> V` | `runOnThread(java.util.concurrent.Callable<V> callable)`

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### User32Util.MessageLoopThread

          public User32Util.MessageLoopThread()

  - ### Method Detail

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.lang.Thread`

    - #### runAsync

          public <V> java.util.concurrent.Future<V> runAsync(java.util.concurrent.Callable<V> command)

    - #### runOnThread

          public <V> V runOnThread(java.util.concurrent.Callable<V> callable)
                        throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### exit

          public void exit()

    - #### getMessageFailed

          protected boolean getMessageFailed()

      The method is called from the thread, that run the message dispatcher, when the call to `User32.GetMessage(com.sun.jna.platform.win32.WinUser.MSG, com.sun.jna.platform.win32.WinDef.HWND, int, int)` fails (returns `-1`).

      If the method returns `true`, the MainLoop is exitted, if it returns `false` the mainloop is resumed.

      Default behavior: The error code is logged to the com.sun.jna.platform.win32.User32Util.MessageLoopThread logger and the main loop exists.

      Returns:
        true if MainLoop should exit, false it it should resume

Copyright © 2007-2016 Timothy Wall. All Rights Reserved.