ICancellationToken.Register Method
Registers a procedure to be called when cancellation is requested.
Remarks
If cancellation was already requested, the callback runs immediately, on the calling thread, before Register returns.
Releasing the registration while its callback is running on another thread waits for the callback to finish, so that nothing the callback uses can be freed under it. Releasing it from inside the callback itself does not wait.
Syntax
Unit: Bcl.Cancellation
function ICancellationToken.Register(const ACallback: TProc): IInterface; virtual; abstract;
Parameters
| <-> | Parameter | Type | Description |
|---|---|---|---|
| const | ACallback | TProc | The procedure to call. It runs on the thread that requests the cancellation, so it must be short and thread safe - typically it wakes up a wait: sets an event, closes a socket, pushes a sentinel into a queue. |
Returns
The registration. Keep the reference for as long as the callback is wanted: releasing it unregisters the callback.