CancellationTokenSource class
Signals to a CancellationToken that it should be canceled.
CancellationTokenSource is used to instantiate a CancellationToken (via the source's token that can be handed to operations that wish to be notified of cancellation or that can be used to register asynchronous operations for cancellation. That token may have cancellation requested by calling to the source's cancel method.
- Inheritance
-
- Object
- Disposable
- CancellationTokenSource
- Implementers
Constructors
- CancellationTokenSource.new([Duration? delay])
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancellationRequested → bool
-
Gets whether cancellation has been requested for this
CancellationTokenSource.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- token → CancellationToken
-
Gets the CancellationToken associated with this
CancellationTokenSource.
no setter
Methods
-
cancel(
[bool throwOnFirstException = false]) → void - Communicates a request for cancellation.
-
cancelAfter(
Duration delay) → void - Schedules a Cancel operation on this CancellationTokenSource.
-
dispose(
) → void -
Performs application-defined tasks associated with freeing, releasing,
or resetting unmanaged resources.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register(
CancellationCallback callback, [Object? state]) → CancellationTokenRegistration - Registers a callback object. If cancellation has already occurred, the callback will have been run by the time this method returns.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
createLinkedTokenSource(
List< CancellationToken> tokens) → CancellationTokenSource - Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens are in the canceled state.
-
onTimer(
Object? state) → void