<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.
namespace Nito.AsyncEx { public interface IAsyncWaitQueue<T> { bool IsEmpty { get; } Task<T> Enqueue(); void Dequeue(T result = default(T)); void DequeueAll(T result = default(T)); bool TryCancel(Task task, CancellationToken cancellationToken); void CancelAll(CancellationToken cancellationToken); } }