System.Collections.Concurrent.BlockingCollection<T>.Take Method

Removes an item from the System.Collections.Concurrent.BlockingCollection`1.

Syntax

public T Take (System.Threading.CancellationToken cancellationToken)

Parameters

cancellationToken
Object that can be used to cancel the take operation.

Returns

The item removed from the collection.

Remarks

A call to BlockingCollection`1.Take(System.Threading.CancellationToken) may block until an item is available to be removed or the token is canceled.

The order in which an item is removed depends on the type of collection used to create the System.Collections.Concurrent.BlockingCollection`1 instance. When you create a System.Collections.Concurrent.BlockingCollection`1 object, you can specify the type of collection to use. For example, you could specify a ConcurrentConcurrentQueue`1 object for first in, first out (FIFO) behavior, or a System.Collections.Concurrent.ConcurrentStack`1 object for last in, first out (LIFO) behavior. You can use any collection class that implements the System.Collections.Concurrent.IProducerConsumerCollection`1 interface. The default collection type for System.Collections.Concurrent.BlockingCollection`1 is System.Collections.Concurrent.ConcurrentQueue`1.

Requirements

Namespace: System.Collections.Concurrent
Assembly: System (in System.dll)
Assembly Versions: 4.0.0.0