Редагувати

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


DataflowBlock.ReceiveAsync Method

Definition

Overloads

ReceiveAsync<TOutput>(ISourceBlock<TOutput>)

Asynchronously receives a value from a specified source.

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

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

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

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

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

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

ReceiveAsync<TOutput>(ISourceBlock<TOutput>)

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

Asynchronously receives a value from a specified source.

public:
generic <typename TOutput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TOutput> ^ ReceiveAsync(System::Threading::Tasks::Dataflow::ISourceBlock<TOutput> ^ source);
public static System.Threading.Tasks.Task<TOutput> ReceiveAsync<TOutput> (this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source);
static member ReceiveAsync : System.Threading.Tasks.Dataflow.ISourceBlock<'Output> -> System.Threading.Tasks.Task<'Output>
<Extension()>
Public Function ReceiveAsync(Of TOutput) (source As ISourceBlock(Of TOutput)) As Task(Of TOutput)

Type Parameters

TOutput

The type of data contained in the source.

Parameters

source
ISourceBlock<TOutput>

The source from which to receive the value.

Returns

Task<TOutput>

A task that represents the asynchronous receive operation. When an item value is successfully received from the source, the returned task is completed and its Result returns the received value. If an item value cannot be retrieved because the source is empty and completed , an InvalidOperationException exception is thrown in the returned task.

Exceptions

source is null.

Applies to

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

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

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

public:
generic <typename TOutput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TOutput> ^ ReceiveAsync(System::Threading::Tasks::Dataflow::ISourceBlock<TOutput> ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<TOutput> ReceiveAsync<TOutput> (this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, System.Threading.CancellationToken cancellationToken);
static member ReceiveAsync : System.Threading.Tasks.Dataflow.ISourceBlock<'Output> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Output>
<Extension()>
Public Function ReceiveAsync(Of TOutput) (source As ISourceBlock(Of TOutput), cancellationToken As CancellationToken) As Task(Of TOutput)

Type Parameters

TOutput

Specifies 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

Task<TOutput>

A task that represents the asynchronous receive operation. When a value is successfully received from the source, the returned task is completed and its Result returns the value. If a value cannot be retrieved because cancellation was requested, the returned task is canceled. If the value cannot be retrieved because the source is empty and completed , an InvalidOperationException exception is thrown in the returned task.

Exceptions

source is null.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

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

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

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

public:
generic <typename TOutput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TOutput> ^ ReceiveAsync(System::Threading::Tasks::Dataflow::ISourceBlock<TOutput> ^ source, TimeSpan timeout);
public static System.Threading.Tasks.Task<TOutput> ReceiveAsync<TOutput> (this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, TimeSpan timeout);
static member ReceiveAsync : System.Threading.Tasks.Dataflow.ISourceBlock<'Output> * TimeSpan -> System.Threading.Tasks.Task<'Output>
<Extension()>
Public Function ReceiveAsync(Of TOutput) (source As ISourceBlock(Of TOutput), timeout As TimeSpan) As Task(Of TOutput)

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

Task<TOutput>

A task that represents the asynchronous receive operation. When a value is successfully received from the source, the returned task is completed and its Result returns the value. If a value cannot be retrieved because the time-out expired, the returned task is canceled. If the value cannot be retrieved because the source is empty and completed , an InvalidOperationException exception is thrown in the returned task.

Exceptions

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.

Applies to

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

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

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

public:
generic <typename TOutput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TOutput> ^ ReceiveAsync(System::Threading::Tasks::Dataflow::ISourceBlock<TOutput> ^ source, TimeSpan timeout, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<TOutput> ReceiveAsync<TOutput> (this System.Threading.Tasks.Dataflow.ISourceBlock<TOutput> source, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
static member ReceiveAsync : System.Threading.Tasks.Dataflow.ISourceBlock<'Output> * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Output>
<Extension()>
Public Function ReceiveAsync(Of TOutput) (source As ISourceBlock(Of TOutput), timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of TOutput)

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 which may be used to cancel the receive operation.

Returns

Task<TOutput>

A task that represents the asynchronous receive operation. When a value is successfully received from the source, the returned task is completed and its Result returns the value. If a value cannot be retrieved because the time-out expired or cancellation was requested, the returned task is canceled. If the value cannot be retrieved because the source is empty and completed, an InvalidOperationException exception is thrown in the returned task.

Exceptions

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.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to