System.Collections.Concurrent.ConcurrentBag<T> Class

Represents a thread-safe, unordered collection of objects.

See Also: ConcurrentBag<T> Members

Syntax

[System.Diagnostics.DebuggerDisplay("Count={Count}")]
[System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.Generic.CollectionDebuggerView`1))]
[System.Runtime.InteropServices.ComVisible(false)]
public class ConcurrentBag<T> : IProducerConsumerCollection<T>, IEnumerable<T>

Type Parameters

T
Documentation for this section has not yet been entered.

Remarks

Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates. System.Collections.Concurrent.ConcurrentBag`1 is a thread-safe bag implementation, optimized for scenarios where the same thread will be both producing and consuming data stored in the bag.

System.Collections.Concurrent.ConcurrentBag`1 accepts null as a valid value for reference types.

For more information, see the entry tp://blogs.msdn.com/b/pfxteam/archive/2010/01/26/9953725.aspx in the Parallel Programming with .NET blog.

Requirements

Namespace: System.Collections.Concurrent
Assembly: System (in System.dll)
Assembly Versions: 4.0.0.0