BlockingCollection<T>.TakeFromAny BlockingCollection<T>.TakeFromAny BlockingCollection<T>.TakeFromAny BlockingCollection<T>.TakeFromAny Method

Definition

Takes an item from any one of the specified BlockingCollection<T> instances.

Overloads

TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T)

Takes an item from any one of the specified BlockingCollection<T> instances.

TakeFromAny(BlockingCollection<T>[], T, CancellationToken) TakeFromAny(BlockingCollection<T>[], T, CancellationToken) TakeFromAny(BlockingCollection<T>[], T, CancellationToken)

Takes an item from any one of the specified BlockingCollection<T> instances while observing the specified cancellation token.

TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T) TakeFromAny(BlockingCollection<T>[], T)

Takes an item from any one of the specified BlockingCollection<T> instances.

public:
 static int TakeFromAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, [Runtime::InteropServices::Out] T % item);
public static int TakeFromAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, out T item);
static member TakeFromAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T -> int
Public Shared Function TakeFromAny (collections As BlockingCollection(Of T)(), ByRef item As T) As Integer

Parameters

collections
BlockingCollection<T>[]

The array of collections.

item
T T T T

The item removed from one of the collections.

Returns

The index of the collection in the collections array from which the item was removed.

Exceptions

The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

The collections argument is a 0-length array or contains a null element or CompleteAdding() has been called on the collection.

At least one of the underlying collections was modified outside of its BlockingCollection<T> instance.

Remarks

A call to TakeFromAny may block until an item is available to be removed.

See also

TakeFromAny(BlockingCollection<T>[], T, CancellationToken) TakeFromAny(BlockingCollection<T>[], T, CancellationToken) TakeFromAny(BlockingCollection<T>[], T, CancellationToken)

Takes an item from any one of the specified BlockingCollection<T> instances while observing the specified cancellation token.

public:
 static int TakeFromAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, [Runtime::InteropServices::Out] T % item, System::Threading::CancellationToken cancellationToken);
public static int TakeFromAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, out T item, System.Threading.CancellationToken cancellationToken);
static member TakeFromAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T * System.Threading.CancellationToken -> int

Parameters

collections
BlockingCollection<T>[]

The array of collections.

item
T T T T

The item removed from one of the collections.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

A cancellation token to observe.

Returns

The index of the collection in the collections array from which the item was removed.

Exceptions

At least one of the underlying collections was modified outside of its BlockingCollection<T> instance.

The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

The collections argument is a 0-length array or contains a null element, or CompleteAdding() has been called on the collection.

Remarks

A call to TakeFromAny may block until an item is available to be removed. The method will return early with an OperationCanceledException if the token is canceled.

See also

Applies to