CancellationToken Structure

Task Parallel System.Threading

Propogates notification that operations should be canceled.

Namespace:  System.Threading
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
	ExternalThreading := True)> _
Public Structure CancellationToken
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, 
	ExternalThreading = true)]
public struct CancellationToken

Remarks

A CancellationToken may be created directly in an unchangeable canceled or non-canceled state using the CancellationToken's constructors. However, to have a CancellationToken that can change from a non-canceled to a canceled state, CancellationTokenSource must be used. CancellationTokenSource exposes the associated CancellationToken that may be canceled by the source through its Token property.

Once canceled, a token may not transition to a non-canceled state, and a token whose CanBeCanceled is false will never change to one that can be canceled.

All members of this struct are thread-safe and may be used concurrently from multiple threads.

See Also