<?xml version="1.0" encoding="utf-8"?> <Type Name="ConcurrentBag<T>" FullName="System.Collections.Concurrent.ConcurrentBag<T>"> <TypeSignature Language="C#" Value="public class ConcurrentBag<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>" /> <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ConcurrentBag`1<T> extends System.Object implements class System.Collections.Concurrent.IProducerConsumerCollection`1<!T>, class System.Collections.Generic.IEnumerable`1<!T>, class System.Collections.ICollection, class System.Collections.IEnumerable" /> <AssemblyInfo> <AssemblyName>System</AssemblyName> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <TypeParameters> <TypeParameter Name="T" /> </TypeParameters> <Base> <BaseTypeName>System.Object</BaseTypeName> </Base> <Interfaces> <Interface> <InterfaceName>System.Collections.Concurrent.IProducerConsumerCollection<T></InterfaceName> </Interface> <Interface> <InterfaceName>System.Collections.Generic.IEnumerable<T></InterfaceName> </Interface> </Interfaces> <Attributes> <Attribute> <AttributeName>System.Diagnostics.DebuggerDisplay("Count={Count}")</AttributeName> </Attribute> <Attribute> <AttributeName>System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.Generic.CollectionDebuggerView`1))</AttributeName> </Attribute> <Attribute> <AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName> </Attribute> </Attributes> <Docs> <typeparam name="T">To be added.</typeparam> <remarks> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates. <see cref="T: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. </para> <para> <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" /> accepts null as a valid value for reference types. </para> <para>For more information, see the entry <see cref="http://blogs.msdn.com/b/pfxteam/archive/2010/01/26/9953725.aspx">FAQ: Are all of the new concurrent collections lock-free?</see> in the Parallel Programming with .NET blog.</para> </remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Represents a thread-safe, unordered collection of objects.</para> </summary> </Docs> <Members> <Member MemberName=".ctor"> <MemberSignature Language="C#" Value="public ConcurrentBag ();" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> <MemberType>Constructor</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <Parameters /> <Docs> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Initializes a new instance of the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" /> class.</para> </summary> </Docs> </Member> <Member MemberName=".ctor"> <MemberSignature Language="C#" Value="public ConcurrentBag (System.Collections.Generic.IEnumerable<T> collection);" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Collections.Generic.IEnumerable`1<!T> collection) cil managed" /> <MemberType>Constructor</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <Parameters> <Parameter Name="collection" Type="System.Collections.Generic.IEnumerable<T>" /> </Parameters> <Docs> <param name="collection">To be added.</param> <summary>To be added.</summary> <remarks>To be added.</remarks> </Docs> </Member> <Member MemberName="Add"> <MemberSignature Language="C#" Value="public void Add (T item);" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Add(!T item) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="item" Type="T" /> </Parameters> <Docs> <param name="item">To be added.</param> <summary>To be added.</summary> <remarks>To be added.</remarks> </Docs> </Member> <Member MemberName="CopyTo"> <MemberSignature Language="C#" Value="public void CopyTo (T[] array, int index);" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void CopyTo(!T[] array, int32 index) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="array" Type="T[]" /> <Parameter Name="index" Type="System.Int32" /> </Parameters> <Docs> <param name="array">To be added.</param> <param name="index">To be added.</param> <summary>To be added.</summary> <remarks>To be added.</remarks> </Docs> </Member> <Member MemberName="Count"> <MemberSignature Language="C#" Value="public int Count { get; }" /> <MemberSignature Language="ILAsm" Value=".property instance int32 Count" /> <MemberType>Property</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Int32</ReturnType> </ReturnValue> <Docs> <value>To be added.</value> <remarks> <attribution license="cc4" from="Microsoft" modified="false" /> <para>The count returned represents a moment-in-time snapshot of the contents of the bag. It is possible that other threads might add or remove items immediately after you access the Count property.</para> </remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Gets the number of elements contained in the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </summary> </Docs> </Member> <Member MemberName="GetEnumerator"> <MemberSignature Language="C#" Value="public System.Collections.Generic.IEnumerator<T> GetEnumerator ();" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance class System.Collections.Generic.IEnumerator`1<!T> GetEnumerator() cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Collections.Generic.IEnumerator<T></ReturnType> </ReturnValue> <Parameters /> <Docs> <remarks> <attribution license="cc4" from="Microsoft" modified="false" /> <para>The enumeration represents a moment-in-time snapshot of the contents of the bag. It does not reflect any updates to the collection after <see cref="M:System.Collections.Concurrent.ConcurrentBag`1.GetEnumerator" /> was called. The enumerator is safe to use concurrently with reads from and writes to the bag.</para> </remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Returns an enumerator that iterates through the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </summary> <returns> <attribution license="cc4" from="Microsoft" modified="false" /> <para>An enumerator for the contents of the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </returns> </Docs> </Member> <Member MemberName="IsEmpty"> <MemberSignature Language="C#" Value="public bool IsEmpty { get; }" /> <MemberSignature Language="ILAsm" Value=".property instance bool IsEmpty" /> <MemberType>Property</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Docs> <value>To be added.</value> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Gets a value that indicates whether the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" /> is empty.</para> </summary> </Docs> </Member> <Member MemberName="System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd"> <MemberSignature Language="C#" Value="bool IProducerConsumerCollection<T>.TryAdd (T element);" /> <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance bool System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd(!T element) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Parameters> <Parameter Name="element" Type="T" /> </Parameters> <Docs> <param name="element">To be added.</param> <summary>To be added.</summary> <returns>To be added.</returns> <remarks>To be added.</remarks> </Docs> </Member> <Member MemberName="System.Collections.ICollection.CopyTo"> <MemberSignature Language="C#" Value="void ICollection.CopyTo (Array array, int index);" /> <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void System.Collections.ICollection.CopyTo(class System.Array array, int32 index) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="array" Type="System.Array" /> <Parameter Name="index" Type="System.Int32" /> </Parameters> <Docs> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Copies the elements of the <see cref="T:System.Collections.ICollection" /> to an <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.</para> </summary> <param name="array"> <attribution license="cc4" from="Microsoft" modified="false" />The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param> <param name="index"> <attribution license="cc4" from="Microsoft" modified="false" />The zero-based index in <paramref name="array" /> at which copying begins.</param> </Docs> </Member> <Member MemberName="System.Collections.ICollection.IsSynchronized"> <MemberSignature Language="C#" Value="bool System.Collections.ICollection.IsSynchronized { get; }" /> <MemberSignature Language="ILAsm" Value=".property instance bool System.Collections.ICollection.IsSynchronized" /> <MemberType>Property</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Docs> <value>To be added.</value> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection" /> is synchronized with the SyncRoot.</para> </summary> </Docs> </Member> <Member MemberName="System.Collections.ICollection.SyncRoot"> <MemberSignature Language="C#" Value="object System.Collections.ICollection.SyncRoot { get; }" /> <MemberSignature Language="ILAsm" Value=".property instance object System.Collections.ICollection.SyncRoot" /> <MemberType>Property</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Object</ReturnType> </ReturnValue> <Docs> <value>To be added.</value> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />. This property is not supported.</para> </summary> </Docs> </Member> <Member MemberName="System.Collections.IEnumerable.GetEnumerator"> <MemberSignature Language="C#" Value="System.Collections.IEnumerator IEnumerable.GetEnumerator ();" /> <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance class System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Collections.IEnumerator</ReturnType> </ReturnValue> <Parameters /> <Docs> <remarks> <attribution license="cc4" from="Microsoft" modified="false" /> <para>The items enumerated represent a moment-in-time snapshot of the contents of the bag. It does not reflect any update to the collection after <see cref="M:System.Collections.Concurrent.ConcurrentBag`1.GetEnumerator" /> was called.</para> </remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Returns an enumerator that iterates through the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </summary> <returns> <attribution license="cc4" from="Microsoft" modified="false" /> <para>An enumerator for the contents of the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </returns> </Docs> </Member> <Member MemberName="ToArray"> <MemberSignature Language="C#" Value="public T[] ToArray ();" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance !T[] ToArray() cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>T[]</ReturnType> </ReturnValue> <Parameters /> <Docs> <remarks>To be added.</remarks> <summary> <attribution license="cc4" from="Microsoft" modified="false" /> <para>Copies the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" /> elements to a new array.</para> </summary> <returns> <attribution license="cc4" from="Microsoft" modified="false" /> <para>A new array containing a snapshot of elements copied from the <see cref="T:System.Collections.Concurrent.ConcurrentBag`1" />.</para> </returns> </Docs> </Member> <Member MemberName="TryPeek"> <MemberSignature Language="C#" Value="public bool TryPeek (out T result);" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig instance bool TryPeek(!T result) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Parameters> <Parameter Name="result" Type="T&" RefType="out" /> </Parameters> <Docs> <param name="result">To be added.</param> <summary>To be added.</summary> <returns>To be added.</returns> <remarks>To be added.</remarks> </Docs> </Member> <Member MemberName="TryTake"> <MemberSignature Language="C#" Value="public bool TryTake (out T result);" /> <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool TryTake(!T result) cil managed" /> <MemberType>Method</MemberType> <AssemblyInfo> <AssemblyVersion>4.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Parameters> <Parameter Name="result" Type="T&" RefType="out" /> </Parameters> <Docs> <param name="result">To be added.</param> <summary>To be added.</summary> <returns>To be added.</returns> <remarks>To be added.</remarks> </Docs> </Member> </Members> </Type>