public interface Revocable
TaskDispatcher.asyncDispatch(java.lang.Runnable),
TaskDispatcher.delayDispatch(java.lang.Runnable, long), or
TaskDispatcher.asyncGroupDispatch(ohos.app.dispatcher.Group, java.lang.Runnable).
The following example shows how to use this interface to revoke an asynchronous task:
void postTaskAndRevoke(Context context) {
TaskDispatcher dispatcher = context.getUITaskDispatcher();
System.out.println("1");
Revocable revocable = dispatcher.delayDispatch(new Runnable(){
System.out.println("delay dispatch");
}, 10);
boolean revoked = revocable.revoke();
System.out.println(revoked);
}
// A typical result is :
// true
boolean revoke()
Revocable object.
If the task is running or has completed, this method cannot revoke it and returns false.
true if the revocation is successful; returns false if it fails because the
task is running or has completed.