Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct System.​Threading.​CancellationToken
Assembly: System.Runtime
Propagates notification that operations should be canceled.
Properties
public
bool
CanBeCanceled
Gets whether this token is capable of being in the canceled state.
public
bool
IsCancellationRequested
Gets whether cancellation has been requested for this token.
public
WaitHandle
WaitHandle
Gets a <see cref="T:System.Threading.WaitHandle" /> that is signaled when the token is canceled.
Methods
public
bool
Equals​(object other)
other
The other object to compare with this instance.
Returns <see langword="true" /> if <paramref name="other" /> is a <see cref="T:System.Threading.CancellationToken" /> and if the two instances are equal; otherwise, <see langword="false" /> . See the Remarks section for more information.
Determines whether the current <see cref="T:System.Threading.CancellationToken" /> instance is equal to the specified <see cref="T:System.Object" /> .
public
bool
Equals​(CancellationToken other)
other
The other <see cref="T:System.Threading.CancellationToken" /> to compare with this instance.
Returns <see langword="true" /> if the instances are equal; otherwise, <see langword="false" /> . See the Remarks section for more information.
Determines whether the current <see cref="T:System.Threading.CancellationToken" /> instance is equal to the specified token.
public
int
GetHashCode​() Returns A hash code for the current <see cref="T:System.Threading.CancellationToken" /> instance.
Serves as a hash function for a <see cref="T:System.Threading.CancellationToken" /> .
Register​(Action callback)
callback
The delegate to be executed when the <see cref="T:System.Threading.CancellationToken" /> is canceled.
Returns The <see cref="T:System.Threading.CancellationTokenRegistration" /> instance that can be used to unregister the callback.
Registers a delegate that will be called when this <see cref="T:System.Threading.CancellationToken" /> is canceled.
Register​(Action callback,
bool useSynchronizationContext)
callback
The delegate to be executed when the <see cref="T:System.Threading.CancellationToken" /> is canceled.
useSynchronizationContext
A value that indicates whether to capture the current <see cref="T:System.Threading.SynchronizationContext" /> and use it when invoking the <paramref name="callback" /> .
Returns The <see cref="T:System.Threading.CancellationTokenRegistration" /> instance that can be used to unregister the callback.
Registers a delegate that will be called when this <see cref="T:System.Threading.CancellationToken" /> is canceled.
public
void
ThrowIfCancellationRequested​()
Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.
public
string
ToString​()
Inherited from ValueType
Returns The fully qualified type name.
Returns the fully qualified type name of this instance.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .