TKMCancellationTokenSource

This class provides functionality to cancel pending promises. It is a source for cancellation tokens.

The example below demonstrates how to retrieve a CancellationToken and use it to cancel a pending operation.

let cancellationTokenSource = TKMCancellationTokenSource()
let ct = cancellationTokenSource.token

//Pass the token to an asynchronous operation that accepts a CancellationToken
asyncOperation(..., ct).conclude()

// If required, cancellation can be requested as follows:
cancellationTokenSource.requestCancellation()

See also

TKMPromise<T>