Class AsyncQueue<T>
Provides a synchronized queue which can be used from within async operations. This is primarily used for producer/consumer scenarios.
Inheritance
Inherited Members
Namespace:Microsoft.SqlTools.ServiceLayer.Utility
Assembly:Microsoft.SqlTools.ServiceLayer.dll
Syntax
public class AsyncQueue<T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of item contained in the queue. |
Constructors
| Improve this Doc View SourceAsyncQueue()
Initializes an empty instance of the AsyncQueue class.
Declaration
public AsyncQueue()
AsyncQueue(IEnumerable<T>)
Initializes an instance of the AsyncQueue class, pre-populated with the given collection of items.
Declaration
public AsyncQueue(IEnumerable<T> initialItems)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | initialItems | An IEnumerable containing the initial items with which the queue will be populated. |
Properties
| Improve this Doc View SourceIsEmpty
Returns true if the queue is currently empty.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceDequeueAsync()
Dequeues an item from the queue or waits asynchronously until an item is available.
Declaration
public Task<T> DequeueAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | A Task which can be awaited until a value can be dequeued. |
DequeueAsync(CancellationToken)
Dequeues an item from the queue or waits asynchronously until an item is available. The wait can be cancelled using the given CancellationToken.
Declaration
public Task<T> DequeueAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken | A CancellationToken with which a dequeue wait can be cancelled. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | A Task which can be awaited until a value can be dequeued. |
EnqueueAsync(T)
Enqueues an item onto the end of the queue.
Declaration
public Task EnqueueAsync(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to be added to the queue. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A Task which can be awaited until the synchronized enqueue operation completes. |