DataflowBlock.Receive Method

Definition

Overloads

Receive<TOutput>(ISourceBlock<TOutput>)

Synchronously receives a value from a specified source.

Receive<TOutput>(ISourceBlock<TOutput>, CancellationToken)

Synchronously receives a value from a specified source and provides a token to cancel the operation.

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan)

Synchronously receives a value from a specified source, observing an optional time-out period.

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)

Synchronously receives a value from a specified source, providing a token to cancel the operation and observing an optional time-out interval.

Receive<TOutput>(ISourceBlock<TOutput>)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Synchronously receives a value from a specified source.

C#
public static TOutput Receive<TOutput>(this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source);

Type Parameters

TOutput

The type of data contained in the source.

Parameters

source
ISourceBlock<TOutput>

The source from which to receive the value.

Returns

TOutput

The received value.

Exceptions

source is null.

No item could be received from the source.

Applies to

.NET 10 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
UWP 10.0

Receive<TOutput>(ISourceBlock<TOutput>, CancellationToken)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Synchronously receives a value from a specified source and provides a token to cancel the operation.

C#
public static TOutput Receive<TOutput>(this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, System.Threading.CancellationToken cancellationToken);

Type Parameters

TOutput

The type of data contained in the source.

Parameters

source
ISourceBlock<TOutput>

The source from which to receive the value.

cancellationToken
CancellationToken

The token to use to cancel the receive operation.

Returns

TOutput

The received value.

Exceptions

source is null.

No item could be received from the source.

The operation was canceled before an item was received from the source.

Remarks

If the source successfully offered an item that was received by this operation, that item is returned even if a concurrent cancellation request occurs.

Applies to

.NET 10 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
UWP 10.0

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Synchronously receives a value from a specified source, observing an optional time-out period.

C#
public static TOutput Receive<TOutput>(this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, TimeSpan timeout);

Type Parameters

TOutput

The type of data contained in the source.

Parameters

source
ISourceBlock<TOutput>

The source from which to receive the value.

timeout
TimeSpan

The maximum time interval, in milliseconds, to wait for the synchronous operation to complete, or an interval that represents -1 milliseconds to wait indefinitely.

Returns

TOutput

The received value.

Exceptions

timeout is a negative number other than -1 milliseconds, which represents an infinite time-out period.

-or-

timeout is greater than Int32.MaxValue.

source is null.

No item could be received from the source.

The specified time-out expired before an item was received from the source.

Remarks

If the source successfully offered an item that was received by this operation, that item is returned even if a concurrent time-out occurs.

Applies to

.NET 10 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
UWP 10.0

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)

Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs
Source:
DataflowBlock.cs

Synchronously receives a value from a specified source, providing a token to cancel the operation and observing an optional time-out interval.

C#
public static TOutput Receive<TOutput>(this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);

Type Parameters

TOutput

The type of data contained in the source.

Parameters

source
ISourceBlock<TOutput>

The source from which to receive the value.

timeout
TimeSpan

The maximum time interval, in milliseconds, to wait for the synchronous operation to complete, or an interval that represents -1 milliseconds to wait indefinitely.

cancellationToken
CancellationToken

The token to use to cancel the receive operation.

Returns

TOutput

The received value.

Exceptions

The source is null.

timeout is a negative number other than -1 milliseconds, which represents an infinite time-out period.

-or-

timeout is greater than Int32.MaxValue.

No item could be received from the source.

The specified time-out expired before an item was received from the source.

The operation was canceled before an item was received from the source.

Remarks

If the source successfully offered an item value that was received by this operation, that value is returned even if a concurrent time-out or cancellation request occurs.

Applies to

.NET 10 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
UWP 10.0