DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="4.6.1" />

 TaskCompletionPipe<T>

public class TaskCompletionPipe<T> : IAsyncEnumerable<T> where T : Task
Represents a pipe to process asynchronous tasks as they complete.
public TaskCompletionPipe(int capacity = 0)

Initializes a new pipe.

public void Add(T task)

Adds the task to this pipe.

public void Complete()

Marks the pipe as being complete, meaning no more items will be added to it.

Gets the enumerator to get the completed tasks.

public void Reset(int capacity = 0)

Reuses the pipe.

public bool TryRead(out T task)

Attempts to read the completed task synchronously.

public ValueTask<bool> WaitToReadAsync(TimeSpan timeout, CancellationToken token = default)

Waits for the first completed task.

public ValueTask<bool> WaitToReadAsync(CancellationToken token = default)

Waits for the first completed task.