Class PromiseWithCancellation
- Namespace
- MarymoorStudios.Core.Promises
- Assembly
- MarymoorStudios.Core.Promises.dll
public static class PromiseWithCancellation
- Inheritance
-
PromiseWithCancellation
- Inherited Members
Methods
WithCancellation(Promise, CancellationToken)
Adds the ability to cancel awaiting on an underlying promise.
public static Promise WithCancellation(this Promise target, CancellationToken cancel)
Parameters
targetPromiseThe underlying promise.
cancelCancellationTokenA token to indicate that awaiting on
targetshould be cancelled.
Returns
- Promise
A promise that either is cancelled or forwarded to the underlying promise.
Remarks
Cancellation ONLY cancels the awaiting on the underlying promise, not the underlying promise itself or the eventual computation that will produce that promise. To cancel the eventual computation itself a CancellationToken should be passed to that computation when it is started.
WithCancellation<T>(Promise<T>, CancellationToken)
Adds the ability to cancel awaiting on an underlying promise.
public static Promise<T> WithCancellation<T>(this Promise<T> target, CancellationToken cancel)
Parameters
targetPromise<T>The underlying promise.
cancelCancellationTokenA token to indicate that awaiting on
targetshould be cancelled.
Returns
- Promise<T>
A promise that either is cancelled or forwarded to the underlying promise.
Type Parameters
TThe type of the underlying promise.
Remarks
Cancellation ONLY cancels the awaiting on the underlying promise, not the underlying promise itself or the eventual computation that will produce that promise. To cancel the eventual computation itself a CancellationToken should be passed to that computation when it is started.