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>

表示线程安全的先进先出 (FIFO) 集合。 Represents a thread-safe first in-first out (FIFO) collection.

ConcurrentStack<T>

表示线程安全的后进先出 (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>

定义用于操作供生产者/使用者使用的线程安全集合的方法。 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

指定控制分区程序的缓冲行为的选项 Specifies options to control the buffering behavior of a partitioner