DataflowBlock.SendAsync 方法

定义

重载

名称 说明
SendAsync<TInput>(ITargetBlock<TInput>, TInput, CancellationToken)

以异步方式向目标消息块提供消息,从而允许推迟。

SendAsync<TInput>(ITargetBlock<TInput>, TInput)

以异步方式向目标消息块提供消息,从而允许推迟。

SendAsync<TInput>(ITargetBlock<TInput>, TInput, CancellationToken)

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

以异步方式向目标消息块提供消息,从而允许推迟。

public:
generic <typename TInput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<bool> ^ SendAsync(System::Threading::Tasks::Dataflow::ITargetBlock<TInput> ^ target, TInput item, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<bool> SendAsync<TInput>(this System.Threading.Tasks.Dataflow.ITargetBlock<TInput> target, TInput item, System.Threading.CancellationToken cancellationToken);
static member SendAsync : System.Threading.Tasks.Dataflow.ITargetBlock<'Input> * 'Input * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
<Extension()>
Public Function SendAsync(Of TInput) (target As ITargetBlock(Of TInput), item As TInput, cancellationToken As CancellationToken) As Task(Of Boolean)

类型参数

TInput

指定要发布到目标的数据的类型。

参数

target
ITargetBlock<TInput>

要向其发布数据的目标。

item
TInput

提供给目标的项目。

cancellationToken
CancellationToken

请求取消发送操作的取消令牌。

返回

表示异步发送的 A Task<TResult> 。 如果目标在调用 SendAsync 期间接受和使用提供的元素,则从调用返回时,生成的 Task<TResult> 元素将完成,并且其 Result 属性将返回 true。 如果目标在调用期间拒绝提供的元素,则从调用返回时,生成的 Task<TResult> 元素将完成,其 Result 属性将返回 false。 如果目标推迟提供的元素,则会缓冲该元素,直到目标使用或释放它,此时任务将完成,并 Result 指示消息是否被使用。 如果目标永远不会尝试使用或释放消息,则返回的任务永远不会完成。

如果在目标成功使用发送的数据之前请求取消,则返回的任务将以“已取消”状态完成,并且数据将不再可供目标使用。

例外

target为 null(Visual Basic 中无任何内容)。

取消令牌已取消。 此异常存储在返回的任务中。

适用于

SendAsync<TInput>(ITargetBlock<TInput>, TInput)

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

以异步方式向目标消息块提供消息,从而允许推迟。

public:
generic <typename TInput>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<bool> ^ SendAsync(System::Threading::Tasks::Dataflow::ITargetBlock<TInput> ^ target, TInput item);
public static System.Threading.Tasks.Task<bool> SendAsync<TInput>(this System.Threading.Tasks.Dataflow.ITargetBlock<TInput> target, TInput item);
static member SendAsync : System.Threading.Tasks.Dataflow.ITargetBlock<'Input> * 'Input -> System.Threading.Tasks.Task<bool>
<Extension()>
Public Function SendAsync(Of TInput) (target As ITargetBlock(Of TInput), item As TInput) As Task(Of Boolean)

类型参数

TInput

指定要发布到目标的数据的类型。

参数

target
ITargetBlock<TInput>

要向其发布数据的目标。

item
TInput

提供给目标的项目。

返回

表示异步发送的 A Task<TResult> 。 如果目标在调用期间接受和使用提供的元素,则从调用 SendAsync<TInput>(ITargetBlock<TInput>, TInput)返回后,生成的 Task<TResult> 元素将完成,其 Result 属性将返回 true。 如果目标在调用期间拒绝提供的元素,则从调用返回时,生成的 Task<TResult> 元素将完成,其 Result 属性将返回 false。 如果目标推迟提供的元素,则元素将缓冲到目标使用或释放该元素的此类时间,此时任务将完成,并 Result 指示消息是否被使用。 如果目标永远不会尝试使用或释放消息,则返回的任务永远不会完成。

例外

targetnull

适用于