generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::ICollection
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::ICollection
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.ICollection
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface ICollection
    interface IReadOnlyCollection<'T>
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface ICollection
    interface IReadOnlyCollection<'T>
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface IReadOnlyCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
Public Class ConcurrentQueue(Of T)
Implements ICollection, IEnumerable(Of T), IProducerConsumerCollection(Of T), IReadOnlyCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements IEnumerable(Of T), IProducerConsumerCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements IEnumerable(Of T), IProducerConsumerCollection(Of T), IReadOnlyCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements ICollection, IEnumerable(Of T), IProducerConsumerCollection(Of T)
// ConcurrentQueue<T>.Enqueue() // ConcurrentQueue<T>.TryPeek() // ConcurrentQueue<T>.TryDequeue() static void Main () // Construct a ConcurrentQueue. ConcurrentQueue<int> cq = new ConcurrentQueue<int>(); // Populate the queue. for (int i = 0; i < 10000; i++) cq.Enqueue(i); // Peek at the first element. int result; if (!cq.TryPeek(out result)) Console.WriteLine("CQ: TryPeek failed when it should have succeeded"); else if (result != 0) Console.WriteLine("CQ: Expected TryPeek result of 0, got {0}", result); int outerSum = 0; // An action to consume the ConcurrentQueue. Action action = () => int localSum = 0; int localValue; while (cq.TryDequeue(out localValue)) localSum += localValue; Interlocked.Add(ref outerSum, localSum); // Start 4 concurrent consuming actions. Parallel.Invoke(action, action, action, action); Console.WriteLine("outerSum = {0}, should be 49995000", outerSum); Imports System.Collections.Concurrent Imports System.Threading Imports System.Threading.Tasks Class TestQueue ' Demonstrates: ' ConcurrentQueue<T>.Enqueue() ' ConcurrentQueue<T>.TryPeek() ' ConcurrentQueue<T>.TryDequeue() Shared Sub Main() ' Construct a ConcurrentQueue Dim cq As New ConcurrentQueue(Of Integer)() ' Populate the queue For i As Integer = 0 To 9999 cq.Enqueue(i) ' Peek at the first element Dim result As Integer If Not cq.TryPeek(result) Then Console.WriteLine("CQ: TryPeek failed when it should have succeeded") ElseIf result <> 0 Then Console.WriteLine("CQ: Expected TryPeek result of 0, got {0}", result) End If Dim outerSum As Integer = 0 ' An action to consume the ConcurrentQueue Dim action As Action = Sub() Dim localSum As Integer = 0 Dim localValue As Integer While cq.TryDequeue(localValue) localSum += localValue End While Interlocked.Add(outerSum, localSum) End Sub ' Start 4 concurrent consuming actions Parallel.Invoke(action, action, action, action) Console.WriteLine("outerSum = {0}, should be 49995000", outerSum) End Sub End Class

ConcurrentQueue<T> IReadOnlyCollection<T> 实现从 .NET Framework 4.6 开始的接口;在.NET Framework的早期版本中, ConcurrentQueue<T> 类未实现此接口。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

枚举并转换序列,然后使用指定的键和值比较器生成其内容的不可变字典。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用默认的相等比较器对键进行比较。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用指定的 IEqualityComparer<T> 对键进行比较。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>, IEqualityComparer<TKey>)

基于匹配键对两个序列的元素进行关联。 使用指定的 IEqualityComparer<T> 对键进行比较。