BlockingCollection<T>.Take メソッド
定義
BlockingCollection<T> から項目を削除します。Removes an item from the BlockingCollection<T>.
オーバーロード
Take() |
BlockingCollection<T> から項目を削除します。Removes an item from the BlockingCollection<T>. |
Take(CancellationToken) |
BlockingCollection<T> から項目を削除します。Removes an item from the BlockingCollection<T>. |
Take()
BlockingCollection<T> から項目を削除します。Removes an item from the BlockingCollection<T>.
public:
T Take();
public T Take ();
member this.Take : unit -> 'T
Public Function Take () As T
戻り値
- T
コレクションから削除される項目。The item removed from the collection.
例外
BlockingCollection<T> は破棄されています。The BlockingCollection<T> has been disposed.
基になるコレクションがこの BlockingCollection<T> インスタンスの外で変更されました。または、BlockingCollection<T> が空で、コレクションが追加完了としてマークされています。The underlying collection was modified outside of this BlockingCollection<T> instance, or the BlockingCollection<T> is empty and the collection has been marked as complete for adding.
BlockingCollection<T> は空であり、追加に関して完了としてマークされました。The BlockingCollection<T> is empty and has been marked as complete with regards to additions.
注釈
を呼び出すと、 Take 項目を削除できるようになるまでブロックされる可能性があります。A call to Take may block until an item is available to be removed.
項目が削除される順序は、BlockingCollection<T> インスタンスの作成に使用されたコレクションの型によって異なります。The order in which an item is removed depends on the type of collection used to create the BlockingCollection<T> instance. BlockingCollection<T> オブジェクトを作成すると、使用するコレクションの型を指定できます。When you create a BlockingCollection<T> object, you can specify the type of collection to use. たとえば、先入れ先出し法 (FIFO) の動作には ConcurrentQueue<T> オブジェクトを指定し、後入れ先出し法 (LIFO) の動作には ConcurrentStack<T> オブジェクトを指定できます。For example, you could specify a ConcurrentQueue<T> object for first in, first out (FIFO) behavior, or a ConcurrentStack<T> object for last in, first out (LIFO) behavior. IProducerConsumerCollection<T> インターフェイスを実装する任意のコレクション クラスを使用できます。You can use any collection class that implements the IProducerConsumerCollection<T> interface. BlockingCollection<T> の既定のコレクション型は ConcurrentQueue<T> です。The default collection type for BlockingCollection<T> is ConcurrentQueue<T>.
適用対象
Take(CancellationToken)
BlockingCollection<T> から項目を削除します。Removes an item from the BlockingCollection<T>.
public:
T Take(System::Threading::CancellationToken cancellationToken);
public T Take (System.Threading.CancellationToken cancellationToken);
member this.Take : System.Threading.CancellationToken -> 'T
Public Function Take (cancellationToken As CancellationToken) As T
パラメーター
- cancellationToken
- CancellationToken
取得操作を取り消すために使用できるオブジェクト。Object that can be used to cancel the take operation.
戻り値
- T
コレクションから削除される項目。The item removed from the collection.
例外
CancellationToken は取り消されます。The CancellationToken is canceled.
BlockingCollection<T> が破棄されているか、トークンを作成した CancellationTokenSource が取り消されています。The BlockingCollection<T> has been disposed or the CancellationTokenSource that created the token was canceled.
基になるコレクションがこの BlockingCollection<T> インスタンスの外で変更されたか、BlockingCollection が追加完了としてマークされているか、BlockingCollection<T> が空です。The underlying collection was modified outside of this BlockingCollection<T> instance or the BlockingCollection is marked as complete for adding, or the BlockingCollection<T> is empty.
注釈
を呼び出すと、 Take 項目が削除されるか、トークンが取り消されるまでブロックされることがあります。A call to Take may block until an item is available to be removed or the token is canceled.
項目が削除される順序は、BlockingCollection<T> インスタンスの作成に使用されたコレクションの型によって異なります。The order in which an item is removed depends on the type of collection used to create the BlockingCollection<T> instance. BlockingCollection<T> オブジェクトを作成すると、使用するコレクションの型を指定できます。When you create a BlockingCollection<T> object, you can specify the type of collection to use. たとえば、先入れ先出し法 (FIFO) の動作には ConcurrentQueue<T> オブジェクトを指定し、後入れ先出し法 (LIFO) の動作には ConcurrentStack<T> オブジェクトを指定できます。For example, you could specify a ConcurrentQueue<T> object for first in, first out (FIFO) behavior, or a ConcurrentStack<T> object for last in, first out (LIFO) behavior. IProducerConsumerCollection<T> インターフェイスを実装する任意のコレクション クラスを使用できます。You can use any collection class that implements the IProducerConsumerCollection<T> interface. BlockingCollection<T> の既定のコレクション型は ConcurrentQueue<T> です。The default collection type for BlockingCollection<T> is ConcurrentQueue<T>.