Android SDK Version


public final class CancellationToken
Propagates notification that operations should be canceled.
Create an instance of CancellationTokenSource and pass the token returned from CancellationTokenSource.token to the asynchronous operation(s). Call CancellationTokenSource#cancel() to cancel the operations.
A CancellationToken can only be cancelled once - it should not be passed to future operations once cancelled.
Field Summary
Modifier and TypeFieldDescription
private final BooleanisCancellationRequested
Method Summary
Modifier and TypeMethodDescription
final BooleangetIsCancellationRequested()
final CancellationTokenRegistrationregister(Runnable action) Registers a runnable that will be called when this CancellationToken is canceled.
final UnitthrowIfCancellationRequested()
StringtoString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail

getIsCancellationRequested

 final BooleangetIsCancellationRequested()

register

 final CancellationTokenRegistrationregister(Runnable action)
Registers a runnable that will be called when this CancellationToken is canceled. If this token is already in the canceled state, the runnable will be run immediately and synchronously.
Parameters:
action - the runnable to be run when the token is cancelled.

throwIfCancellationRequested

 final UnitthrowIfCancellationRequested()

toString

StringtoString()