<PackageReference Include="Nito.AsyncEx.Coordination" Version="1.0.2" />

Nito.AsyncEx.IAsyncWaitQueue<T>

public interface IAsyncWaitQueue<T>
A collection of cancelable TaskCompletionSource<T> instances. Implementations must assume the caller is holding a lock.
bool IsEmpty { get; }

Gets whether the queue is empty.

void CancelAll(CancellationToken cancellationToken)

Removes all entries from the wait queue and cancels them. The task continuations for the completed tasks must be executed asynchronously.

void Dequeue(T result = null)

Removes a single entry in the wait queue and completes it. This method may only be called if IsEmpty is false. The task continuations for the completed task must be executed asynchronously.

void DequeueAll(T result = null)

Removes all entries in the wait queue and completes them. The task continuations for the completed tasks must be executed asynchronously.

Creates a new entry and queues it to this wait queue. The returned task must support both synchronous and asynchronous waits.

bool TryCancel(Task task, CancellationToken cancellationToken)

Attempts to remove an entry from the wait queue and cancels it. The task continuations for the completed task must be executed asynchronously.