public abstract class LongOperation extends Object implements Runnable, Cancellable
| Constructor and Description |
|---|
LongOperation(CockpitThreadContextCreator cockpitThreadContextCreator) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
activate()
activate the thread (and cached desktop) for UI updates call
deactivate() once done updating the UI |
void |
cancel()
set the cancelled flag and try to interrupt the thread
|
protected void |
checkCancelled()
Checks if the task thread has been interrupted.
|
protected void |
deactivate()
deactivate the current active (see:
activate()) thread/desktop after updates are done |
protected abstract void |
execute()
asynchronous callback for your long operation code
|
boolean |
isCancelled()
check the cancelled flag
|
protected void |
onCancel()
optional callback method when the task has been cancelled or was interrupted otherwise
|
protected void |
onCleanup()
Optional callback method when the task has completed (always called)
|
protected void |
onException(Throwable exception)
optional callback method when the task has completed with an uncaught Exception
|
protected void |
onFinish()
Callback method which is executed in Ui thread after long operation finishes.
|
void |
run() |
void |
start()
launch the long operation
|
public LongOperation(CockpitThreadContextCreator cockpitThreadContextCreator)
cockpitThreadContextCreator - util used to copy ctx from ui thread to background thread.protected abstract void execute()
throws InterruptedException
InterruptedException - if operation has been Interruptedprotected void onFinish()
protected void onCancel()
protected void onException(Throwable exception)
exception - thrown exceptionprotected void onCleanup()
public final void cancel()
cancel in interface Cancellablepublic final boolean isCancelled()
protected final boolean activate()
throws InterruptedException
deactivate() once done updating the UIInterruptedException - if it is interrupted by other threadprotected final void deactivate()
activate()) thread/desktop after updates are doneprotected final void checkCancelled()
throws InterruptedException
InterruptedException - when the current task has been cancelled/interruptedpublic final void start()
Copyright © 2018. All rights reserved.