CancellationToken

CancellationToken class

Propagates notification that operations should be canceled. This class provides a mechanism for cooperative cancellation between threads, allowing one thread to notify others that an operation should be canceled.

class CancellationToken : public System::Details::BoxableObjectBase

Methods

MethodDescription
CancellationToken()Default constructor.
bool get_CanBeCanceled() constGets whether this token is capable of being in the canceled state.
bool get_IsCancellationRequested() constGets whether cancellation has been requested for this token.
static CancellationToken get_None()Returns an empty System::Threading::CancellationToken value.
CancellationTokenRegistration Register(const Action<>&) constRegisters a callback that will be invoked when cancellation is requested.
void ThrowIfCancellationRequested() constThrows a OperationCanceledException if cancellation has been requested.

Remarks

A CancellationToken can only be canceled through its associated CancellationTokenSource.

See Also