Table of Contents

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

target Promise

The underlying promise.

cancel CancellationToken

A token to indicate that awaiting on target should 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

target Promise<T>

The underlying promise.

cancel CancellationToken

A token to indicate that awaiting on target should be cancelled.

Returns

Promise<T>

A promise that either is cancelled or forwarded to the underlying promise.

Type Parameters

T

The 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.