Click or drag to resize
AsyncCancellationTokenRegister Method
Registers a callback which executes on cancellation. If token is already cancelled, callback is executed immediately.

Namespace: PatchKit.Async
Assembly: PatchKit.Async (in PatchKit.Async.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public AsyncCancellationTokenRegistration Register(
	Action callback
)

Parameters

callback
Type: SystemAction
Callback to execute.

Return Value

Type: AsyncCancellationTokenRegistration
Registration which can be used to unregister the callback by disposing the registration object.
Exceptions
ExceptionCondition
ArgumentNullExceptioncallback is null.
Examples
// Register cancellation callback var registration = cancellationToken.Register(() => Thread.CurrentThread.Abort); // Callback will be unregistered after leaving using scope. using(registration) { // Some operations }
See Also