class · System.Threading

BlockingCollection<T>

public class System.Threading.BlockingCollection<T> : System.Any

A queue that hands items from producers to consumers: Take waits for an item; after CompleteAdding, Take on an empty queue throws and TryTake gives false.

Kind
class
Namespace
System.Threading
Assembly
System.Core
Access
public, final
Source file
Threading.ant

Type parameters

NameConstraints
Tany type

Inheritance

Base classes
Any BlockingCollection<T>

Constructors

constructor BlockingCollection()
#

Properties

property IsAddingCompleted: bool
#

read-only

property IsCompleted: bool
#

read-only

property Count: i32
#

read-only

Methods

method Add(item: T) -> void
#
method Take() -> T
#

The next item (waiting for one).

method WaitForItem() -> bool
#

Whether an item can be taken (waiting for one, unless adding is complete); then Take gives it at once to this consumer only if no other one takes it first.

method CompleteAdding() -> void
#
method Dispose() -> void
#

Frees what it holds (it must not be used after).

Private and internal members (5)

field mutex: System.Threading.Mutex
#

private

field changed: System.Threading.Condition
#

private

field items: System.Queue<T>
#

private

field completed: bool
#

private

field waiters: i32
#

private

Inherited members (5)

Source

BlockingCollection<T> as Larva HIR, decompiled from its Larva HIR.

System.Threading.BlockingCollection.hir
// A queue that hands items from producers to consumers: Take waits for an item; after CompleteAdding, Take on an
// empty queue throws and TryTake gives false.
public class System.Threading.BlockingCollection<T> : System.Any
{
    field mutex: System.Threading.Mutex
    field changed: System.Threading.Condition
    field items: System.Queue<T>
    field completed: bool
    field waiters: i32
    constructor BlockingCollection()
    method Add(item: T) -> void
    // The next item (waiting for one).
    method Take() -> T
    // Whether an item can be taken (waiting for one, unless adding is complete); then Take gives it at once to
    // this consumer only if no other one takes it first.
    method WaitForItem() -> bool
    method CompleteAdding() -> void
    // Frees what it holds (it must not be used after).
    method Dispose() -> void
    property IsAddingCompleted: bool
    property IsCompleted: bool
    property Count: i32
}
Esc