| AsyncCancellationTokenRegister Method |
Registers a callback which executes on cancellation. If token is already cancelled, callback is executed immediately.
Namespace: PatchKit.AsyncAssembly: PatchKit.Async (in PatchKit.Async.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic AsyncCancellationTokenRegistration Register(
Action callback
)
Parameters
- callback
- Type: SystemAction
Callback to execute.
Return Value
Type:
AsyncCancellationTokenRegistrationRegistration which can be used to unregister the callback by disposing the registration object.
Exceptions
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