CancellationToken.Register CancellationToken.Register CancellationToken.Register CancellationToken.Register Method

Definition

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

Overloads

Register(Action) Register(Action) Register(Action) Register(Action)

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

Register(Action, Boolean) Register(Action, Boolean) Register(Action, Boolean) Register(Action, Boolean)

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

Register(Action<Object>, Object) Register(Action<Object>, Object) Register(Action<Object>, Object) Register(Action<Object>, Object)

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

Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean)

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

Register(Action) Register(Action) Register(Action) Register(Action)

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

public:
 System::Threading::CancellationTokenRegistration Register(Action ^ callback);
public System.Threading.CancellationTokenRegistration Register (Action callback);
member this.Register : Action -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action) As CancellationTokenRegistration
Parameters
callback
Action Action Action Action

The delegate to be executed when the CancellationToken is canceled.

Returns
Exceptions

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 propagated out of this method call.

The current ExecutionContext is captured along with the delegate and will be used when executing it.

The current SynchronizationContext is not captured.

See Also

Register(Action, Boolean) Register(Action, Boolean) Register(Action, Boolean) Register(Action, Boolean)

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

public:
 System::Threading::CancellationTokenRegistration Register(Action ^ callback, bool useSynchronizationContext);
public System.Threading.CancellationTokenRegistration Register (Action callback, bool useSynchronizationContext);
member this.Register : Action * bool -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action, useSynchronizationContext As Boolean) As CancellationTokenRegistration
Parameters
callback
Action Action Action Action

The delegate to be executed when the CancellationToken is canceled.

useSynchronizationContext
Boolean Boolean Boolean Boolean

A value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Returns
Exceptions

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 propagated out of this method call.

The current ExecutionContext is captured along with the delegate and will be used when executing it.

If useSynchronizationContext is true, the current SynchronizationContext, if one exists, is also captured along with the delegate and will be used when executing it. Otherwise, SynchronizationContext is not captured.

See Also

Register(Action<Object>, Object) Register(Action<Object>, Object) Register(Action<Object>, Object) Register(Action<Object>, Object)

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

public:
 System::Threading::CancellationTokenRegistration Register(Action<System::Object ^> ^ callback, System::Object ^ state);
public System.Threading.CancellationTokenRegistration Register (Action<object> callback, object state);
member this.Register : Action<obj> * obj -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action(Of Object), state As Object) As CancellationTokenRegistration
Parameters
callback
Action<Object>

The delegate to be executed when the CancellationToken is canceled.

state
Object Object Object Object

The state to pass to the callback when the delegate is invoked. This may be null.

Returns
Exceptions

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 propagated out of this method call.

The current ExecutionContext is captured along with the delegate and will be used when executing it.

The current SynchronizationContext is not captured.

See Also

Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean) Register(Action<Object>, Object, Boolean)

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

public:
 System::Threading::CancellationTokenRegistration Register(Action<System::Object ^> ^ callback, System::Object ^ state, bool useSynchronizationContext);
public System.Threading.CancellationTokenRegistration Register (Action<object> callback, object state, bool useSynchronizationContext);
member this.Register : Action<obj> * obj * bool -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action(Of Object), state As Object, useSynchronizationContext As Boolean) As CancellationTokenRegistration
Parameters
callback
Action<Object>

The delegate to be executed when the CancellationToken is canceled.

state
Object Object Object Object

The state to pass to the callback when the delegate is invoked. This may be null.

useSynchronizationContext
Boolean Boolean Boolean Boolean

A Boolean value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Returns
Exceptions

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 propagated out of this method call.

The current ExecutionContext is captured along with the delegate and will be used when executing it.

If useSynchronizationContext is true, the current SynchronizationContext, if one exists, is also captured along with the delegate and will be used when executing it. Otherwise, SynchronizationContext is not captured.

See Also

Applies to