The BackgroundTask is an interface that describes the
operations available for checking on the status of a running task.
There are methods available for checking if the task is finished,
if the task was successfully completed, and for cancelling the
task. Query implementations may extend this interface to
provide an interface method for fetching the resultant query data.
Waits until the task is finished (i.e., isFinished() returns true).
Method Detail
isFinished
boolean isFinished()
Fetch whether this task is completed or not. Returns true if
this task was completed (sucessful or failed with exception) or
cancelled, or false if the task is still running or has not been
started yet.
Returns:
true if the task is finished or cancelled, false otherwise
waitUntilFinished
void waitUntilFinished()
Waits until the task is finished (i.e., isFinished() returns true).
This will block the current thread.
cancel
void cancel()
Attempts to cancel the current task in progress. This does not
guarantee the task will be cancelled immediately, as it is
implementation dependent, though implementations are strongly
encouraged to ensure a speedy cancellation. Clients should not
fetch or use the query results when a cancel is issued, as the
results are unpredictable.
getProgress
int getProgress()
Fetches the current progress of the query task. This will return
an integer between 0 (just started) and 100 (finished). This is
solely an estimate, and is not guaranteed to be accurate, though
implementations are encouraged to try to provide an accurate number.
This can be used by clients to display a progress bar for example.
Returns:
a progress value between 0 and 100 to denote the running
status of this task
getProgressText
java.lang.String getProgressText()
Fetches a human-readable (translated) descriptive text that
describes what the task is currently doing. Implementations should
try to make this information actually usable and informative for
users. This can be used by clients to display with a progress bar
for example.
Returns:
a human-readable description of the current task's progress