System
4.0.0.0
System.Object
System.Collections.Generic.IEnumerable<T>
System.Collections.ICollection
System.IDisposable
System.Diagnostics.DebuggerDisplay("Count={Count}")
System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.Generic.CollectionDebuggerView`1))
System.Runtime.InteropServices.ComVisible(false)
To be added.
is a thread-safe collection class that provides the following:
-
An implementation of the producer/consumer pattern; is a wrapper for the interface.
-
Concurrent addition and removal of items from multiple threads with the and methods.
-
A bounded collection that blocks and operations when the collection is full or empty.
-
Cancellation of or operations by using a object in the or method.
represents a collection that allows for thread-safe adding and removal of data. is used as a wrapper for an instance, and allows removal attempts from the collection to block until data is available to be removed. Similarly, you can create a to enforce an upper bound on the number of data elements allowed in the ; addition attempts to the collection may then block until space is available to store the added items. In this manner, is similar to a traditional blocking queue data structure, except that the underlying data storage mechanism is abstracted away as an .
supports bounding and blocking. Bounding means that you can set the maximum capacity of the collection. Bounding is important in certain scenarios because it enables you to control the maximum size of the collection in memory, and it prevents the producing threads from moving too far ahead of the consuming threads.Multiple threads or tasks can add items to the collection concurrently, and if the collection reaches its specified maximum capacity, the producing threads will block until an item is removed. Multiple consumers can remove items concurrently, and if the collection becomes empty, the consuming threads will block until a producer adds an item. A producing thread can call the method to indicate that no more items will be added. Consumers monitor the property to know when the collection is empty and no more items will be added.
and operations are typically performed in a loop. You can cancel a loop by passing in a object to the or method, and then checking the value of the token's property on each iteration. If the value is true, it is up to you to respond the cancellation request by cleaning up any resources and exiting the loop.
When you create a object, you can specify not only the bounded capacity but also the type of collection to use. For example, you could specify a object for first in, first out (FIFO) behavior, or a object for last in, first out (LIFO) behavior. You can use any collection class that implements the interface. The default collection type for is .
Do not modify the underlying collection directly. Use methods to add or remove elements. The object can become corrupted if you change the underlying collection directly.
Provides blocking and bounding capabilities for thread-safe collections that implement .
Constructor
4.0.0.0
The default underlying collection is a object, which provides first in, first out (FIFO) behavior.
Initializes a new instance of the class without an upper-bound.
Constructor
4.0.0.0
To be added.
To be added.
To be added.
Constructor
4.0.0.0
The default underlying collection is a .
Initializes a new instance of the class with the specified upper-bound.
The bounded size of the collection.
Constructor
4.0.0.0
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Void
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Void
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Property
4.0.0.0
System.Int32
To be added.
To be added.
Gets the bounded capacity of this instance.
Method
4.0.0.0
System.Void
After a collection has been marked as complete for adding, adding to the collection is not permitted and attempts to remove from the collection will not wait when the collection is empty.
Marks the instances as not accepting any more additions.
Method
4.0.0.0
System.Void
To be added.
To be added.
To be added.
To be added.
Property
4.0.0.0
System.Int32
To be added.
If any method in BlockingCollection is executing while the Count property is being accessd, the return value is approximate. Count may reflect a number that is either greater than or less than the actual number of items in the BlockingCollection.
Gets the number of items contained in the .
Method
4.0.0.0
System.Void
The Dispose method is not thread-safe.
Call Dispose when you are finished using the . The Dispose method leaves the in an unusable state. After calling Dispose, you must release all references to the so the garbage collector can reclaim the memory that the was occupying.
For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
Always call Dispose before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's Finalize method.
Releases all resources used by the current instance of the class.
Method
4.0.0.0
System.Void
To be added.
Releases resources used by the instance.
Whether being disposed explicitly (true) or due to a finalizer (false).
Method
4.0.0.0
System.Collections.Generic.IEnumerable<T>
To be added.
Provides a consuming for items in the collection.
An that removes and returns items from the collection.
Method
4.0.0.0
System.Collections.Generic.IEnumerable<T>
This method enables client code to remove items from the collection by using a foreach loop (For Each in Visual Basic), or or a PLINQ query. The enumerator will continue to provide items (if any exist) until returns true, and if is false the loop blocks until an item becomes available or until the is cancelled.
Provides a consuming for items in the collection.
An that removes and returns items from the collection.
A cancellation token to observe.
Property
4.0.0.0
System.Boolean
To be added.
To be added.
Gets whether this has been marked as complete for adding.
Property
4.0.0.0
System.Boolean
To be added.
To be added.
Gets whether this has been marked as complete for adding and is empty.
Method
4.0.0.0
System.Collections.Generic.IEnumerator<T>
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Void
To be added.
Copies all of the items in the instance to a compatible one-dimensional array, starting at the specified index of the target array.
The one-dimensional array that is the destination of the elements copied from the instance. The array must have zero-based indexing.
The zero-based index in at which copying begins.
Property
4.0.0.0
System.Boolean
To be added.
To be added.
Gets a value indicating whether access to the is synchronized.
Property
4.0.0.0
System.Object
To be added.
To be added.
Gets an object that can be used to synchronize access to the . This property is not supported.
Method
4.0.0.0
System.Collections.IEnumerator
To be added.
Provides an for items in the collection.
An for the items in the collection.
Method
4.0.0.0
T
A call to may block until an item is available to be removed.
The order in which an item is removed depends on the type of collection used to create the instance. When you create a object, you can specify the type of collection to use. For example, you could specify a object for first in, first out (FIFO) behavior, or a object for last in, first out (LIFO) behavior. You can use any collection class that implements the interface. The default collection type for is .
Removes an item from the .
The item removed from the collection.
Method
4.0.0.0
T
A call to may block until an item is available to be removed or the token is canceled.
The order in which an item is removed depends on the type of collection used to create the instance. When you create a object, you can specify the type of collection to use. For example, you could specify a object for first in, first out (FIFO) behavior, or a object for last in, first out (LIFO) behavior. You can use any collection class that implements the interface. The default collection type for is .
Removes an item from the .
The item removed from the collection.
Object that can be used to cancel the take operation.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
T[]
The copied elements are not removed from the collection.
If any method in BlockingCollection is executing while the ToArray method executes, the return value is approximate. ToArray may include items that have already been removed, or exclude items that have already been inserted.
Copies the items from the instance into a new array.
An array containing copies of the elements of the collection.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
Method
4.0.0.0
System.Int32
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.