CancellationToken (open)
A cancellation token provides the notification that an operation is cancelled
It is modelled with .NET CancellationTokens as an example.
Syntax
LOADLIB "wh::promise.whlib";
OBJECTTYPE CancellationToken
Properties
- PROPERTY cancelexception
Exception this token was cancelled with (DEFAULT OBJECT when not cancelled)
Functions
- INTEGER64 FUNCTION AddCallback(FUNCTION PTR func)
Adds a callback that will be called when this token is cancelled. If the token has been cancelled, the function will be called immediately, and 0 is returned. Signature: MACRO func() or MACRO func(OBJECT cancelexception)
- MACRO Check()
Checks if this token has been cancelled, throws the cancel exception when it is
- BOOLEAN FUNCTION IsCancelled()
Returns whether this token has been cancelled
- MACRO RemoveCallback(INTEGER64 id)
Removes a previously registered callback