System.Collections.Concurrent Namespace

System.Collections.Concurrent 命名空間提供數個安全執行緒集合類別,每當有多個執行緒同時存取集合時,應該使用這些類別來代替 System.CollectionsSystem.Collections.Generic 命名空間中的對應類型。 The System.Collections.Concurrent namespace provides several thread-safe collection classes that should be used in place of the corresponding types in the System.Collections and System.Collections.Generic namespaces whenever multiple threads are accessing the collection concurrently. 不過,透過延伸模組方法或明確介面實作存取集合物件的項目不保證是安全執行緒,而且可能需要由呼叫端同步處理。 However, access to elements of a collection object through extension methods or through explicit interface implementations are not guaranteed to be thread-safe and may need to be synchronized by the caller.

類別

BlockingCollection<T>

提供安全執行緒集合適用的封鎖和界限容量,這個集合會實作 IProducerConsumerCollection<T>Provides blocking and bounding capabilities for thread-safe collections that implement IProducerConsumerCollection<T>.

ConcurrentBag<T>

代表安全執行緒的未排序物件集合。Represents a thread-safe, unordered collection of objects.

ConcurrentDictionary<TKey,TValue>

代表索引鍵/值組的安全執行緒集合,此集合可由多個執行緒並行存取。Represents a thread-safe collection of key/value pairs that can be accessed by multiple threads concurrently.

ConcurrentQueue<T>

表示安全執行緒的先進先出 (First In-First Out,FIFO) 集合。Represents a thread-safe first in-first out (FIFO) collection.

ConcurrentStack<T>

表示安全執行緒的後進先出 (Last In-First Out,LIFO) 集合。Represents a thread-safe last in-first out (LIFO) collection.

OrderablePartitioner<TSource>

表示將可排序的資料來源分割成多個分割的特定方式。Represents a particular manner of splitting an orderable data source into multiple partitions.

Partitioner

提供陣列、清單和可列舉值的通用分割策略。Provides common partitioning strategies for arrays, lists, and enumerables.

Partitioner<TSource>

表示將資料來源分割成多個分割的特定方式。Represents a particular manner of splitting a data source into multiple partitions.

介面

IProducerConsumerCollection<T>

定義方法,此方法可用來操作 Producer/Consumer 使用方式的安全執行緒集合。Defines methods to manipulate thread-safe collections intended for producer/consumer usage. 此介面提供生產者/消費者集合的統一表示,因此較高層級的抽象 (如 BlockingCollection<T>) 可以使用集合做為基礎儲存機制。This interface provides a unified representation for producer/consumer collections so that higher level abstractions such as BlockingCollection<T> can use the collection as the underlying storage mechanism.

列舉

EnumerablePartitionerOptions

指定控制 partitioner 緩衝行為的選項。Specifies options to control the buffering behavior of a partitioner