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>)

Synchronously receives a value from a specified source.

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.

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

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

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.

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

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

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 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.

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.

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 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.