Contents
What are the blocks in the TPL Dataflow library?
The TPL Dataflow Library provides several predefined dataflow block types that implement the ISourceBlock , ITargetBlock , and IPropagatorBlock interfaces. These dataflow block types are described in this document in the section Predefined Dataflow Block Types.
What should I know about the actionblock type?
ActionBlock is a great type that drastically simplifies most common producer-consumer scenarios. But even in this case, in order to use it correctly, you should know some key aspects of TPL Dataflow, like default degree of parallelism, behavior of bounded blocks and idea of work-items ownership.
How is thread T1 related to the actionblock?
Thread T1 adds an element to the queue. ActionBlock removes an item and calls the callback. Thread T2 adds an element to the queue. ActionBlock removes an item and calls the callback. Thread T1 adds an element to the queue. ActionBlock can’t call the callback, because degree of parallelism is 2.
When does a source block stop offering a message?
Most source block types stop offering a message after one target accepts that message. One exception to this rule is the BroadcastBlock class, which offers each message to all targets, even if some targets reject the message.
How are dataflow blocks connected in a pipeline?
You can connect dataflow blocks to form pipelines, which are linear sequences of dataflow blocks, or networks, which are graphs of dataflow blocks. A pipeline is one form of network. In a pipeline or network, sources asynchronously propagate data to targets as that data becomes available.
How does the.NET Task Parallel Library ( TPL ) work?
The TPL DataFlow library eases concurrent processing and implements tailored asynchronous parallel workflow and batch queuing. Furthermore, it facilitates the implementation of sophisticated patterns based on combining multiple components that talk to each other by passing messages.
Why is TPL a good tool for parallel workflow?
The TPL DataFlow is a great tool for implementing this pattern, because it has intrinsic support for multiple readers and multiple writers concurrently, and it encourages a pipeline pattern of programming, with producers sending messages to decoupled consumers