AsyncQueue<T>.DequeueAsync(CancellationToken) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a task whose result is the element at the head of the queue.
public System.Threading.Tasks.Task<T> DequeueAsync (System.Threading.CancellationToken cancellationToken = default);
member this.DequeueAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
Public Function DequeueAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of T)
Parameters
- cancellationToken
- CancellationToken
A token whose cancellation signals lost interest in the item. Cancelling this token does not guarantee that the task will be canceled before it is assigned a resulting element from the head of the queue. It is the responsibility of the caller to ensure after cancellation that either the task is canceled, or it has a result which the caller is responsible for then handling.
Returns
A task whose result is the head element.
Exceptions
Thrown when this instance has an empty queue and Complete() has been called.
Also thrown when cancellationToken
is canceled before a work item can be dequeued.