CancellationToken Structure
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Propagates notification that operations should be canceled.
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
The CancellationToken type exposes the following members.
| Name | Description | |
|---|---|---|
|
CanBeCanceled | Gets whether this token is capable of being in the canceled state. |
|
IsCancellationRequested | Gets whether cancellation has been requested for this token. |
|
None | Returns an empty CancellationToken value. |
|
WaitHandle | Gets a WaitHandle that is signaled when the token is canceled. |
| Name | Description | |
|---|---|---|
|
Equals(CancellationToken) | Determines whether the current CancellationToken instance is equal to the specified token. |
|
Equals(Object) | Determines whether the current CancellationToken instance is equal to the specified Object. (Overrides ValueType.Equals(Object).) |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
|
GetHashCode | Serves as a hash function for a CancellationToken. (Overrides ValueType.GetHashCode().) |
|
GetType | Gets the Type of the current instance. (Inherited from Object.) |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
Register(Action) | Registers a delegate that will be called when this CancellationToken is canceled. |
|
Register(Action, Boolean) | Registers a delegate that will be called when this CancellationToken is canceled. |
|
Register(Action<Object>, Object) | Registers a delegate that will be called when this CancellationToken is canceled. |
|
Register(Action<Object>, Object, Boolean) | Registers a delegate that will be called when this CancellationToken is canceled. |
|
ThrowIfCancellationRequested | Throws a OperationCanceledException if this token has had cancellation requested. |
|
ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.) |
| Name | Description | |
|---|---|---|
|
Equality | Determines whether two CancellationToken instances are equal. |
|
Inequality | Determines whether two CancellationToken instances are not equal. |
For more information and code examples see Cancellation in Managed Threads.
Note
|
|---|
|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note