Take Method (CancellationToken)

Task Parallel System.Threading

Takes an item from the BlockingCollection<(Of <(T>)>).

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Take ( _
	cancellationToken As CancellationToken _
) As T
C#
public T Take(
	CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken

Return Value

The item removed from the collection.

Remarks

A call to Take(CancellationToken) may block until an item is available to be removed.

Exceptions

ExceptionCondition
System..::.OperationCanceledExceptionIf the CancellationToken is canceled or the BlockingCollection<(Of <(T>)>) is empty and has been marked as complete with regards to additions.
System..::.ObjectDisposedExceptionThe BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationExceptionThe underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also