|
Uses a Task to be executed in a dedicated thread.
The execute method schedules the task to be executed and returns immediately. The tasks for the same group identifier are queued and executed in order.
The cancel method cancels the running task and all others in the queue
Task
It is the task to be executed.
Containts the following methods:
doInBackground: computes a result. It is executed in a background thread.
done: It is executed on the Event Dispatch Thread if the doInBackground method finish successfully.
canceled: action performed if the task is canceled
handleException: Action performed if the doInBackground, done or canceled method finish with an exception.
setResult and getResult: To transfer the computed result from doInBackground method to done method
Example
TaskManager.execute(0, "Waiting...", new Task<Boolean>(){
@Override
public void doInBackground() throws Exception {
Boolean result = ...
setResult(result);
}
@Override
public void done() {
component.setEnabled(getResult());
}
});
|
|
|