Register()

CancellationToken::Register(const Action<>&) const method

Registers a callback that will be invoked when cancellation is requested.

CancellationTokenRegistration System::Threading::CancellationToken::Register(const Action<> &callback) const

Arguments

ParameterTypeDescription
callbackconst Action<>&The Action<> to execute when cancellation is requested.

Return Value

A CancellationTokenRegistration object that can be used to deregister the callback.

Remarks

If cancellation has already been requested, the callback will be invoked immediately.

The callback should be short-lived and non-blocking as it will be executed on the thread that calls Cancel() on the CancellationTokenSource.

See Also