DataflowBlock.SendAsync 方法

定義

多載

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

非同步提供訊息給目標訊息區,並允許延遲。

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

非同步提供訊息給目標訊息區,並允許延遲。

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

來源:
DataflowBlock.cs
來源:
DataflowBlock.cs
來源:
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

取消語彙基元,用來要求取消傳送作業。

傳回

表示非同步傳送的 Task<TResult>。 如果目標在呼叫 SendAsync 期間接受並取用所提供的專案,則從呼叫傳回時,產生的 Task<TResult> 將會完成,且其 Result 屬性會傳回 true。 如果目標在呼叫期間拒絕提供的專案,則從呼叫傳回時,結果 Task<TResult> 將會完成,且其 Result 屬性會傳回 false。 如果目標延後提供的專案,則會緩衝專案,直到目標取用或放開它為止,此時 Task 將會完成,並 Result 指出是否已取用訊息。 如果目標永遠不會嘗試使用或釋放訊息,則傳回的工作永遠不會完成。

如果在目標已成功地耗用傳送的資料之前已要求取消時,傳回的工作會在已取消狀態下完成,而資料將不再用於目標。

例外狀況

target Visual Basic) 中為 Null (Nothing。

解除標記已取消。 此例外狀況會儲存在傳回的工作中。

適用於

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

來源:
DataflowBlock.cs
來源:
DataflowBlock.cs
來源:
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

提供給目標的項目。

傳回

表示非同步傳送的 Task<TResult>。 如果在呼叫 SendAsync<TInput>(ITargetBlock<TInput>, TInput) 期間目標接受並使用所提供的項目,從呼叫返回時,所產生的 Task<TResult> 將完成,而且其 Result 屬性會傳回 true。 如果在呼叫期間目標拒絕所提供的項目,從呼叫返回時,所產生的 Task<TResult> 將完成,而且其 Result 屬性會傳回 false。 如果目標延後所提供的項目,則會緩衝項目直到目標耗用或釋放項目,此時將會完成工作,而其 Result 指出訊息是否已耗用。 如果目標永遠不會嘗試使用或釋放訊息,則傳回的工作永遠不會完成。

例外狀況

targetnull

適用於