ActionBlock<TInput> Class
Provides a dataflow block that invokes a provided Action<T> delegate for every data element received.
Namespace: System.Threading.Tasks.Dataflow
Assembly: System.Threading.Tasks.Dataflow (in System.Threading.Tasks.Dataflow.dll)
The ActionBlock<TInput> type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | ActionBlock<TInput>(Action<TInput>) | Initializes a new instance of the ActionBlock<TInput> class with the specified action. |
![]() ![]() | ActionBlock<TInput>(Func<TInput, Task>) | Initializes a new instance of the ActionBlock<TInput> class with the specified action. |
![]() ![]() | ActionBlock<TInput>(Action<TInput>, ExecutionDataflowBlockOptions) | Initializes a new instance of the ActionBlock<TInput> class with the specified action and configuration options. |
![]() ![]() | ActionBlock<TInput>(Func<TInput, Task>, ExecutionDataflowBlockOptions) | Initializes a new instance of the ActionBlock<TInput> class with the specified action and configuration options. |
| Name | Description | |
|---|---|---|
![]() ![]() | Completion | Gets a Task object that represents the asynchronous operation and completion of the dataflow block. |
![]() ![]() | InputCount | Gets the number of input items waiting to be processed by this block. |
| Name | Description | |
|---|---|---|
![]() ![]() | Complete | Signals to the dataflow block that it shouldn't accept or produce any more messages and shouldn't consume any more postponed messages. |
![]() ![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() ![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | Post | Posts an item to the target dataflow block. |
![]() ![]() | ToString | Returns a string that represents the formatted name of this IDataflowBlock instance. (Overrides Object::ToString().) |
| Name | Description | |
|---|---|---|
![]() ![]() | AsObserver<TInput> | Creates a new IObserver<T> abstraction over the ITargetBlock<TInput>. (Defined by DataflowBlock.) |
![]() ![]() | Post<TInput> | Posts an item to the ITargetBlock<TInput>. (Defined by DataflowBlock.) |
![]() ![]() | SendAsync<TInput>(TInput) | Overloaded. Asynchronously offers a message to the target message block, allowing for postponement. (Defined by DataflowBlock.) |
![]() ![]() | SendAsync<TInput>(TInput, CancellationToken) | Overloaded. Asynchronously offers a message to the target message block, allowing for postponement. (Defined by DataflowBlock.) |
| Name | Description | |
|---|---|---|
![]() ![]() ![]() | IDataflowBlock::Fault | Causes the dataflow block to complete in a faulted state. |
![]() ![]() ![]() | ITargetBlock<TInput>::OfferMessage | Offers a message to the dataflow block, and gives it the opportunity to consume or postpone the message. |
Note |
|---|
The TPL Dataflow Library (System.Threading.Tasks.Dataflow namespace) is not distributed with the .NET Framework 4.5. To install the System.Threading.Tasks.Dataflow namespace, open your project in Visual Studio 2012, choose Manage NuGet Packages from the Project menu, and search online for the Microsoft.Tpl.Dataflow package. |
The following example shows the use of the ActionBlock<TInput> class to perform several computations using dataflow blocks, and returns the elapsed time required to perform the computations. This code example is part of a larger example provided for the How to: Specify the Degree of Parallelism in a Dataflow Block topic.






Note