System.Threading.CancellationToken.Register Method

Registers a delegate that will be called when this System.Threading.CancellationToken is canceled.

Syntax

public CancellationTokenRegistration Register (Action<object> callback, object state)

Parameters

callback
The delegate to be executed when the System.Threading.CancellationToken is canceled.
state
The state to pass to the callback when the delegate is invoked. This may be null.

Returns

The System.Threading.CancellationTokenRegistration instance that can be used to deregister the callback.

Remarks

If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates will be propogated out of this method call.

The current System.Threading.ExecutionContext, if one exists, will be captured along with the delegate and will be used when executing it.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0