BlockingCollection<T>.TakeFromAny 方法

定義

從任何一個指定的 BlockingCollection<T> 執行個體取得項目。Takes an item from any one of the specified BlockingCollection<T> instances.

多載

TakeFromAny(BlockingCollection<T>[], T)

從任何一個指定的 BlockingCollection<T> 執行個體取得項目。Takes an item from any one of the specified BlockingCollection<T> instances.

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

當觀察指定的取消語彙基元時,接受任何一個指定之 BlockingCollection<T> 執行個體中的項目。Takes an item from any one of the specified BlockingCollection<T> instances while observing the specified cancellation token.

TakeFromAny(BlockingCollection<T>[], T)

從任何一個指定的 BlockingCollection<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

參數

collections
BlockingCollection<T>[]

集合的陣列。The array of collections.

item
T

從其中一個集合移除的項目。The item removed from one of the collections.

傳回

已將其中項目移除之 collections 陣列中的集合索引。The index of the collection in the collections array from which the item was removed.

例外狀況

至少其中一個 BlockingCollection<T> 執行個體已經處置。At least one of the BlockingCollection<T> instances has been disposed.

collections 引數為 null。The collections argument is null.

collections 的計數大於 STA 的上限 62 和 MTA 的上限 63。The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

collections 引數是 0 長度陣列,或者包含 null 項目,或者已在集合呼叫 CompleteAdding()The collections argument is a 0-length array or contains a null element or CompleteAdding() has been called on the collection.

至少其中一個基礎集合已在其 BlockingCollection<T> 執行個體外修改。At least one of the underlying collections was modified outside of its BlockingCollection<T> instance.

備註

呼叫 601.Takefromany 28system.collections.concurrent.blockingcollection 可能會封鎖,直到可以移除專案為止。A call to TakeFromAny may block until an item is available to be removed.

另請參閱

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

當觀察指定的取消語彙基元時,接受任何一個指定之 BlockingCollection<T> 執行個體中的項目。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

參數

collections
BlockingCollection<T>[]

集合的陣列。The array of collections.

item
T

從其中一個集合移除的項目。The item removed from one of the collections.

cancellationToken
CancellationToken

要觀察的取消語彙基元。A cancellation token to observe.

傳回

已將其中項目移除之 collections 陣列中的集合索引。The index of the collection in the collections array from which the item was removed.

例外狀況

至少其中一個基礎集合已在其 BlockingCollection<T> 執行個體外修改。At least one of the underlying collections was modified outside of its BlockingCollection<T> instance.

collections 引數為 null。The collections argument is null.

collections 的計數大於 STA 的上限 62 和 MTA 的上限 63。The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

collections 引數是 0 長度陣列,或者包含 null 項目,或者已在集合呼叫 CompleteAdding()The collections argument is a 0-length array or contains a null element, or CompleteAdding() has been called on the collection.

至少其中一個 BlockingCollection<T> 執行個體已經處置。At least one of the BlockingCollection<T> instances has been disposed.

備註

呼叫 601.Takefromany 28system.collections.concurrent.blockingcollection 可能會封鎖,直到可以移除專案為止。A call to TakeFromAny may block until an item is available to be removed. 如果解除標記,方法會提早傳回 OperationCanceledException。The method will return early with an OperationCanceledException if the token is canceled.

另請參閱

適用於