ewe.sys
Class MessageThreadTask

java.lang.Object
  extended byewe.sys.MessageThreadTask
All Implemented Interfaces:
CallBack

public abstract class MessageThreadTask
extends Object
implements CallBack

This class is used to execute a method within the System Message Thread (which is needed to do certain operations on certain operating systems).

To use it you simply override doTask(). This method will get called in the System Message Thread when the execute() method of the MessageThreadTask is executed.

If execute() is called when the system is already in the Message Thread, then the doTask() method is called immediately. Other wise, the current Coroutine is halted and a CallBack is requested, which will then execute doTask(). After doTask() has been executed the current Coroutine continues and returns the value returned by doTask().


Field Summary
 int timeout
          This is the number of milliseconds to wait before the callBack() completes.
 
Constructor Summary
MessageThreadTask()
           
MessageThreadTask(Window w)
           
 
Method Summary
 void callBack(Object data)
           
protected abstract  boolean doTask(Object data)
          This is the only thing to override.
 boolean execute(Object data)
          Execute the doTask() method in a System Thread.
 boolean execute(Object data, boolean alwaysExecuteNow)
          Execute the doTask() method in a System Thread or in the current thread - depending on the value of alwaysExecuteNow.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

timeout

public int timeout
This is the number of milliseconds to wait before the callBack() completes. By default it is 5000 (5 seconds). If you set it to a value < 0 then there will be no timeout.

Constructor Detail

MessageThreadTask

public MessageThreadTask(Window w)

MessageThreadTask

public MessageThreadTask()
Method Detail

doTask

protected abstract boolean doTask(Object data)
This is the only thing to override. Do the task and return true if successful or false otherwise.


callBack

public final void callBack(Object data)
Specified by:
callBack in interface CallBack

execute

public final boolean execute(Object data)
Execute the doTask() method in a System Thread.

Parameters:
data - The data to be passed to doTask().
Returns:
the value returned by doTask().

execute

public final boolean execute(Object data,
                             boolean alwaysExecuteNow)
Execute the doTask() method in a System Thread or in the current thread - depending on the value of alwaysExecuteNow.

Parameters:
data - The data to be passed to doTask().
alwaysExecuteNow - If this is true then doTask() will always be executed in the current thread.
Returns:
The value returned by doTask().