Читати англійською Редагувати

Поділитися через


BlockingCollection<T> Constructors

Definition

Initializes a new instance of the BlockingCollection<T> class without an upper-bound.

Overloads

BlockingCollection<T>()

Initializes a new instance of the BlockingCollection<T> class without an upper-bound.

BlockingCollection<T>(IProducerConsumerCollection<T>)

Initializes a new instance of the BlockingCollection<T> class without an upper-bound and using the provided IProducerConsumerCollection<T> as its underlying data store.

BlockingCollection<T>(Int32)

Initializes a new instance of the BlockingCollection<T> class with the specified upper-bound.

BlockingCollection<T>(IProducerConsumerCollection<T>, Int32)

Initializes a new instance of the BlockingCollection<T> class with the specified upper-bound and using the provided IProducerConsumerCollection<T> as its underlying data store.

BlockingCollection<T>()

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

Initializes a new instance of the BlockingCollection<T> class without an upper-bound.

C#
public BlockingCollection();

Remarks

The default underlying collection is a ConcurrentQueue<T> object, which provides first in, first out (FIFO) behavior.

See also

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

BlockingCollection<T>(IProducerConsumerCollection<T>)

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

Initializes a new instance of the BlockingCollection<T> class without an upper-bound and using the provided IProducerConsumerCollection<T> as its underlying data store.

C#
public BlockingCollection(System.Collections.Concurrent.IProducerConsumerCollection<T> collection);

Parameters

collection
IProducerConsumerCollection<T>

The collection to use as the underlying data store.

Exceptions

The collection argument is null.

See also

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

BlockingCollection<T>(Int32)

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

Initializes a new instance of the BlockingCollection<T> class with the specified upper-bound.

C#
public BlockingCollection(int boundedCapacity);

Parameters

boundedCapacity
Int32

The bounded size of the collection.

Exceptions

The boundedCapacity is not a positive value.

Remarks

The default underlying collection is a ConcurrentQueue<T>.

See also

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

BlockingCollection<T>(IProducerConsumerCollection<T>, Int32)

Source:
BlockingCollection.cs
Source:
BlockingCollection.cs
Source:
BlockingCollection.cs

Initializes a new instance of the BlockingCollection<T> class with the specified upper-bound and using the provided IProducerConsumerCollection<T> as its underlying data store.

C#
public BlockingCollection(System.Collections.Concurrent.IProducerConsumerCollection<T> collection, int boundedCapacity);

Parameters

collection
IProducerConsumerCollection<T>

The collection to use as the underlying data store.

boundedCapacity
Int32

The bounded size of the collection.

Exceptions

The collection argument is null.

The boundedCapacity is not a positive value.

The supplied collection contains more values than is permitted by boundedCapacity.

See also

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0