Rediger

Del via


BlockingCollection<T>.TakeFromAny Method

Definition

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

Overloads

TakeFromAny(BlockingCollection<T>[], T)

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

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)

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

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);
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

The item that was removed from one of the collections.

Returns

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

Exceptions

At least one of the BlockingCollection<T> instances has been disposed.

The collections argument is null.

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

Applies to

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

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

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);
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
Public Shared Function TakeFromAny (collections As BlockingCollection(Of T)(), ByRef item As T, cancellationToken As CancellationToken) As Integer

Parameters

collections
BlockingCollection<T>[]

The array of collections.

item
T

The item that was removed from one of the collections.

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 collections argument is null.

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 BlockingCollection<T> instances has been disposed.

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