DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="4.0.0-beta.8" />

 ValueTaskCompletionSource

Represents the producer side of ValueTask.
public ValueTaskCompletionSource(bool runContinuationsAsynchronously = true)

Initializes a new completion source.

Creates a fresh task linked with this source.

protected virtual Exception OnCanceled(CancellationToken token)

Called automatically when cancellation detected.

protected virtual Exception OnTimeout()

Called automatically when timeout detected.

public bool TrySetCanceled(short completionToken, CancellationToken token)

Attempts to complete the task unsuccessfully.

public bool TrySetException(short completionToken, Exception e)

Attempts to complete the task unsuccessfully.

public bool TrySetResult()

Attempts to complete the task sucessfully.

public bool TrySetResult(short completionToken)

Attempts to complete the task sucessfully.