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

Nito.AsyncEx.AsyncProducerConsumerQueue<T>

public sealed class AsyncProducerConsumerQueue<T>
An async-compatible producer/consumer queue.
public AsyncProducerConsumerQueue(IEnumerable<T> collection, int maxCount)

Creates a new async-compatible producer/consumer queue with the specified initial elements and a maximum element count.

Creates a new async-compatible producer/consumer queue with the specified initial elements.

public AsyncProducerConsumerQueue(int maxCount)

Creates a new async-compatible producer/consumer queue with a maximum element count.

Creates a new async-compatible producer/consumer queue.

public void CompleteAdding()

Marks the producer/consumer queue as complete for adding.

public T Dequeue(CancellationToken cancellationToken)

Dequeues an item from the producer/consumer queue. Returns the dequeued item. This method may block the calling thread. Throws InvalidOperationException if the producer/consumer queue has completed adding and is empty.

public T Dequeue()

Dequeues an item from the producer/consumer queue. Returns the dequeued item. This method may block the calling thread. Throws InvalidOperationException if the producer/consumer queue has completed adding and is empty.

public Task<T> DequeueAsync(CancellationToken cancellationToken)

Dequeues an item from the producer/consumer queue. Throws InvalidOperationException if the producer/consumer queue has completed adding and is empty.

public Task<T> DequeueAsync()

Dequeues an item from the producer/consumer queue. Returns the dequeued item. Throws InvalidOperationException if the producer/consumer queue has completed adding and is empty.

public void Enqueue(T item, CancellationToken cancellationToken)

Enqueues an item to the producer/consumer queue. This method may block the calling thread. Throws InvalidOperationException if the producer/consumer queue has completed adding.

public void Enqueue(T item)

Enqueues an item to the producer/consumer queue. This method may block the calling thread. Throws InvalidOperationException if the producer/consumer queue has completed adding.

public Task EnqueueAsync(T item, CancellationToken cancellationToken)

Enqueues an item to the producer/consumer queue. Throws InvalidOperationException if the producer/consumer queue has completed adding.

public Task EnqueueAsync(T item)

Enqueues an item to the producer/consumer queue. Throws InvalidOperationException if the producer/consumer queue has completed adding.

Provides a (synchronous) consuming enumerable for items in the producer/consumer queue.

Provides a (synchronous) consuming enumerable for items in the producer/consumer queue.

public bool OutputAvailable(CancellationToken cancellationToken)

Synchronously waits until an item is available to dequeue. Returns false if the producer/consumer queue has completed adding and there are no more items.

public bool OutputAvailable()

Synchronously waits until an item is available to dequeue. Returns false if the producer/consumer queue has completed adding and there are no more items.

public Task<bool> OutputAvailableAsync(CancellationToken cancellationToken)

Asynchronously waits until an item is available to dequeue. Returns false if the producer/consumer queue has completed adding and there are no more items.

public Task<bool> OutputAvailableAsync()

Asynchronously waits until an item is available to dequeue. Returns false if the producer/consumer queue has completed adding and there are no more items.