Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
243 lines (232 sloc) 15.2 KB
<Type Name="IProducerConsumerCollection&lt;T&gt;" FullName="System.Collections.Concurrent.IProducerConsumerCollection&lt;T&gt;">
<TypeSignature Language="C#" Value="public interface IProducerConsumerCollection&lt;T&gt; : System.Collections.Generic.IEnumerable&lt;T&gt;, System.Collections.ICollection" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IProducerConsumerCollection`1&lt;T&gt; implements class System.Collections.Generic.IEnumerable`1&lt;!T&gt;, class System.Collections.ICollection, class System.Collections.IEnumerable" />
<TypeSignature Language="DocId" Value="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />
<TypeSignature Language="VB.NET" Value="Public Interface IProducerConsumerCollection(Of T)&#xA;Implements ICollection, IEnumerable(Of T)" />
<TypeSignature Language="C++ CLI" Value="generic &lt;typename T&gt;&#xA;public interface class IProducerConsumerCollection : System::Collections::Generic::IEnumerable&lt;T&gt;, System::Collections::ICollection" />
<TypeSignature Language="F#" Value="type IProducerConsumerCollection&lt;'T&gt; = interface&#xA; interface seq&lt;'T&gt;&#xA; interface ICollection&#xA; interface IEnumerable" />
<AssemblyInfo>
<AssemblyName>System.Collections.Concurrent</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.14.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeParameters>
<TypeParameter Name="T" />
</TypeParameters>
<Interfaces>
<Interface>
<InterfaceName>System.Collections.Generic.IEnumerable&lt;T&gt;</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.ICollection</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.IEnumerable</InterfaceName>
</Interface>
</Interfaces>
<Docs>
<typeparam name="T">Specifies the type of elements in the collection.</typeparam>
<summary>Defines methods to manipulate thread-safe collections intended for producer/consumer usage. This interface provides a unified representation for producer/consumer collections so that higher level abstractions such as <see cref="T:System.Collections.Concurrent.BlockingCollection`1" /> can use the collection as the underlying storage mechanism.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For more information, see [Thread-Safe Collections](https://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd) and [BlockingCollection Overview](~/docs/standard/collections/thread-safe/blockingcollection-overview.md).
## Examples
The following example shows a stack data structure that implements <xref:System.Collections.Concurrent.IProducerConsumerCollection%601?displayProperty=nameWithType>.
[!code-csharp[System.Collections.Concurrent.IProducerConsumerCollection#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.collections.concurrent.iproducerconsumercollection/cs/iprodcon.cs#1)]
[!code-vb[System.Collections.Concurrent.IProducerConsumerCollection#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.concurrent.iproducerconsumercollection/vb/iprodcon.vb#1)]
]]></format>
</remarks>
<threadsafe>All implementations of this interface must enable all members of this interface to be used concurrently from multiple threads.</threadsafe>
<related type="Article" href="https://msdn.microsoft.com/library/4c2492de-3876-4873-b5a1-000bb404d770">How to: Add Bounding and Blocking Functionality to a Collection Class</related>
</Docs>
<Members>
<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" />
<MemberSignature Language="DocId" Value="M:System.Collections.Concurrent.IProducerConsumerCollection`1.CopyTo(`0[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub CopyTo (array As T(), index As Integer)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void CopyTo(cli::array &lt;T&gt; ^ array, int index);" />
<MemberSignature Language="F#" Value="abstract member CopyTo : 'T[] * int -&gt; unit" Usage="iProducerConsumerCollection.CopyTo (array, index)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Collections.Concurrent</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.14.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.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">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.
The array must have zero-based indexing.</param>
<param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
<summary>Copies the elements of the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" /> to an <see cref="T:System.Array" />, starting at a specified index.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The method provides a snapshot of the underlying collection. It is possible for other threads to add or remove items immediately after the copy is made.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="array" /> is a null reference (Nothing in Visual Basic).</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="index" /> is less than zero.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="index" /> is equal to or greater than the length of the <paramref name="array" /> -or- The number of elements in the collection is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd">Thread-Safe Collections</related>
<related type="Article" href="https://msdn.microsoft.com/library/987ea3d7-0ad5-4238-8b64-331ce4eb3f0b">BlockingCollection Overview</related>
<related type="Article" href="https://msdn.microsoft.com/library/4c2492de-3876-4873-b5a1-000bb404d770">How to: Add Bounding and Blocking Functionality to a Collection Class</related>
</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" />
<MemberSignature Language="DocId" Value="M:System.Collections.Concurrent.IProducerConsumerCollection`1.ToArray" />
<MemberSignature Language="VB.NET" Value="Public Function ToArray () As T()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; cli::array &lt;T&gt; ^ ToArray();" />
<MemberSignature Language="F#" Value="abstract member ToArray : unit -&gt; 'T[]" Usage="iProducerConsumerCollection.ToArray " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Collections.Concurrent</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.14.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>T[]</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Copies the elements contained in the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" /> to a new array.</summary>
<returns>A new array containing the elements copied from the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The method provides a snapshot of the underlying collection. It is possible for other threads to add or remove items immediately after the array is made.
]]></format>
</remarks>
<related type="Article" href="https://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd">Thread-Safe Collections</related>
<related type="Article" href="https://msdn.microsoft.com/library/987ea3d7-0ad5-4238-8b64-331ce4eb3f0b">BlockingCollection Overview</related>
<related type="Article" href="https://msdn.microsoft.com/library/4c2492de-3876-4873-b5a1-000bb404d770">How to: Add Bounding and Blocking Functionality to a Collection Class</related>
</Docs>
</Member>
<Member MemberName="TryAdd">
<MemberSignature Language="C#" Value="public bool TryAdd (T item);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool TryAdd(!T item) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Collections.Concurrent.IProducerConsumerCollection`1.TryAdd(`0)" />
<MemberSignature Language="VB.NET" Value="Public Function TryAdd (item As T) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; bool TryAdd(T item);" />
<MemberSignature Language="F#" Value="abstract member TryAdd : 'T -&gt; bool" Usage="iProducerConsumerCollection.TryAdd item" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Collections.Concurrent</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.14.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="item" Type="T" />
</Parameters>
<Docs>
<param name="item">The object to add to the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.</param>
<summary>Attempts to add an object to the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.</summary>
<returns>true if the object was added successfully; otherwise, false.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">The <paramref name="item" /> was invalid for this collection.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd">Thread-Safe Collections</related>
<related type="Article" href="https://msdn.microsoft.com/library/987ea3d7-0ad5-4238-8b64-331ce4eb3f0b">BlockingCollection Overview</related>
<related type="Article" href="https://msdn.microsoft.com/library/4c2492de-3876-4873-b5a1-000bb404d770">How to: Add Bounding and Blocking Functionality to a Collection Class</related>
</Docs>
</Member>
<Member MemberName="TryTake">
<MemberSignature Language="C#" Value="public bool TryTake (out T item);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool TryTake([out] !T&amp; item) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Collections.Concurrent.IProducerConsumerCollection`1.TryTake(`0@)" />
<MemberSignature Language="VB.NET" Value="Public Function TryTake (ByRef item As T) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; bool TryTake([Runtime::InteropServices::Out] T % item);" />
<MemberSignature Language="F#" Value="abstract member TryTake : -&gt; bool" Usage="iProducerConsumerCollection.TryTake item" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Collections.Concurrent</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.14.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="item" Type="T" RefType="out" />
</Parameters>
<Docs>
<param name="item">When this method returns, if the object was removed and returned successfully, <paramref name="item" /> contains the removed object. If no object was available to be removed, the value is unspecified.</param>
<summary>Attempts to remove and return an object from the <see cref="T:System.Collections.Concurrent.IProducerConsumerCollection`1" />.</summary>
<returns>true if an object was removed and returned successfully; otherwise, false.</returns>
<remarks>To be added.</remarks>
<related type="Article" href="https://msdn.microsoft.com/library/2e7ca21f-786c-4367-96be-0cf3f3dcc6bd">Thread-Safe Collections</related>
<related type="Article" href="https://msdn.microsoft.com/library/987ea3d7-0ad5-4238-8b64-331ce4eb3f0b">BlockingCollection Overview</related>
<related type="Article" href="https://msdn.microsoft.com/library/4c2492de-3876-4873-b5a1-000bb404d770">How to: Add Bounding and Blocking Functionality to a Collection Class</related>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.