DataflowBlock.Post<TInput> Method

.NET Framework (current version)

Posts an item to the ITargetBlock<TInput>.

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

public static bool Post<TInput>(
	this ITargetBlock<TInput> target,
	TInput item

Type Parameters


Specifies the type of data accepted by the target block.


Type: System.Threading.Tasks.Dataflow.ITargetBlock<TInput>

The target block.

Type: TInput

The item being offered to the target.

Return Value

Type: System.Boolean
true if the item was accepted by the target block; otherwise, false.

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

This method will return once the target block has decided to accept or decline the item, but unless otherwise dictated by special semantics of the target block, it does not wait for the item to actually be processed. For example, ActionBlock<TInput> will return from Post<TInput> as soon as it has stored the posted item into its input queue). From the perspective of the block's processing, Post is asynchronous. For target blocks that support postponing offered messages, or for blocks that may do more processing in their Post implementation, consider using SendAsync, which will return immediately and will enable the target to postpone the posted message and later consume it after SendAsync returns.

.NET Framework

Supported in: 4.5

Portable Class Library

Supported in: Portable Class Library