BlockingCollection<T>.Add BlockingCollection<T>.Add BlockingCollection<T>.Add BlockingCollection<T>.Add Method

Definition

Adds the item to the BlockingCollection<T>.

Overloads

Add(T) Add(T) Add(T) Add(T)

Adds the item to the BlockingCollection<T>.

Add(T, CancellationToken) Add(T, CancellationToken) Add(T, CancellationToken)

Adds the item to the BlockingCollection<T>.

Add(T) Add(T) Add(T) Add(T)

Adds the item to the BlockingCollection<T>.

public:
 void Add(T item);
public void Add (T item);
member this.Add : 'T -> unit
Public Sub Add (item As T)
Parameters
item

The item to be added to the collection. The value can be a null reference.

Exceptions

The BlockingCollection<T> has been marked as complete with regards to additions.

-or-

The underlying collection didn't accept the item.

Remarks

If a bounded capacity was specified when this instance of BlockingCollection<T> was initialized, a call to Add may block until space is available to store the provided item.

Add(T, CancellationToken) Add(T, CancellationToken) Add(T, CancellationToken)

Adds the item to the BlockingCollection<T>.

public:
 void Add(T item, System::Threading::CancellationToken cancellationToken);
public void Add (T item, System.Threading.CancellationToken cancellationToken);
member this.Add : 'T * System.Threading.CancellationToken -> unit
Parameters
item

The item to be added to the collection. The value can be a null reference.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

A cancellation token to observe.

Exceptions

The BlockingCollection<T> has been marked as complete with regards to additions.

-or-

The underlying collection didn't accept the item.

Remarks

If a bounded capacity was specified when this instance of BlockingCollection<T> was initialized, a call to Add may block until space is available to store the provided item.

This method can return early with an OperationCanceledException if the cancellationToken is canceled.

Applies to