Export (0) Print
Expand All

DataflowBlock.SendAsync(TInput) Method (ITargetBlock(TInput), TInput, CancellationToken)

.NET Framework 4.5

Asynchronously offers a message to the target message block, allowing for postponement.

Namespace:  System.Threading.Tasks.Dataflow
Assembly:  System.Threading.Tasks.Dataflow (in System.Threading.Tasks.Dataflow.dll)

static member SendAsync : 
        target:ITargetBlock<'TInput> * 
        item:'TInput * 
        cancellationToken:CancellationToken -> Task<bool> 

Type Parameters

TInput

Specifies the type of the data to post to the target.

Parameters

target
Type: System.Threading.Tasks.Dataflow.ITargetBlock(TInput)

The target to which to post the data.

item
Type: TInput

The item being offered to the target.

cancellationToken
Type: System.Threading.CancellationToken

The cancellation token with which to request cancellation of the send operation.

Return Value

Type: System.Threading.Tasks.Task(Boolean)
A Task(TResult) that represents the asynchronous send. If the target accepts and consumes the offered element during the call to SendAsync, upon return from the call the resulting Task(TResult) will be completed and its Result property will return true. If the target declines the offered element during the call, upon return from the call the resulting Task(TResult) will be completed and its Result property will return false. If the target postpones the offered element, the element will be buffered until such time that the target consumes or releases it, at which point the Task will complete, with its Result indicating whether the message was consumed. If the target never attempts to consume or release the message, the returned task will never complete.
If cancellation is requested before the target has successfully consumed the sent data, the returned task will complete in the Canceled state and the data will no longer be available to the target.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ITargetBlock(TInput). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ExceptionCondition
ArgumentNullException

The target is null (Nothing in Visual Basic).

.NET Framework

Supported in: 4.5

Portable Class Library

Supported in: Portable Class Library

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft