tpl-dataflow

Combining dataflow results

不问归期 提交于 2020-01-24 22:15:08
问题 I am develop a Dataflow pipeline which reads a collection of files and, for each line in each file, performs a series of Dataflow blocks. After all steps have completed for each line in a file, I am wanting to execute further blocks on the file itself, but I don't know how this is possible. It is straightforward to split processing via a TransformManyBlock , but how can one then consolidate? I am used to Apache Camel's Splitter and Aggregator functionality - or there a fundamental disconnect

What is the opposite block of BatchBlock

孤者浪人 提交于 2020-01-24 19:00:33
问题 Given : A list of ids of emails What I'm doing : With the BatchBlock group ids and call a Transformblock for each block the simplified transformblock looks like this: var readBatch = new TransformBlock<List<int>, IEnumerable<Email>>(idList => { List<Email> mails = new List<Email>(); foreach(var id in idList) { mails.Add(new Email(id)); } return mails; }); Now my next TransformBlock is defined like this TransformBlock<Email,EMail> filterStep; What I search : So I need a block which allows me

Producer/ Consumer pattern using threads and EventWaitHandle

久未见 提交于 2020-01-23 01:22:08
问题 I guess it is sort of a code review, but here is my implementation of the producer / consumer pattern. What I would like to know is would there be a case in which the while loops in the ReceivingThread() or SendingThread() methods might stop executing. Please note that EnqueueSend(DataSendEnqeueInfo info) is called from multiple different threads and I probably can't use tasks here since I definitely have to consume commands in a separate thread. private Thread mReceivingThread; private

Async logging throwing a NullReferenceException

点点圈 提交于 2020-01-21 03:06:27
问题 I am trying to asynchronously log some information to SQL Server inside of an MVC 4 controller action targeting .NET 4.0 using the AsyncTargetingPack. I would jump straight to .NET 4.5 but my app lives in Azure and we're still waiting for the update... This code works as expected (a row is written to my database with no exceptions thrown): public class SystemActionLogger : ISystemActionLogger { private readonly ActionBlock<Tuple<SystemAction, object>> actionBlock; public SystemActionLogger

TransformBlock never completes

我是研究僧i 提交于 2020-01-13 08:04:50
问题 I'm trying to wrap my head around "completion" in TPL Dataflow blocks. In particular, the TransformBlock doesn't seem to ever complete. Why? Sample program My code calculates the square of all integers from 1 to 1000. I used a BufferBlock and a TransformBlock for that. Later in my code, I await completion of the TransformBlock . The block never actually completes though, and I don't understand why. static void Main(string[] args) { var bufferBlock = new BufferBlock<int>(); var calculatorBlock

Aggregation and Joins (Inner, Outer, Left, …) with TPL-Dataflow?

那年仲夏 提交于 2020-01-02 07:12:53
问题 Is there any better way to implement functions like aggregation within a TPL-Dataflow mesh than using a BatchBlock to buffer all items until completion, emit them as a collection and then use a transform block to do the actual aggregation? Similarly, is there any other way to do an inner/outer/left/right join of two datasets without using a BatchedJoinBlock to buffer all items of both datasources, emit them as a tuple of two collections and then do the actual join with a Transform block? 回答1:

TPL Dataflow, whats the functional difference between Post() and SendAsync()?

大城市里の小女人 提交于 2019-12-28 05:35:09
问题 I am confused about the difference between sending items through Post() or SendAsync(). My understanding is that in all cases once an item reached the input buffer of a data block, control is returned to the calling context, correct? Then why would I ever need SendAsync? If my assumption is incorrect then I wonder, on the contrary, why anyone would ever use Post() if the whole idea of using data blocks is to establish a concurrent and async environment. I understand of course the difference

Data Propagation in TPL Dataflow Pipeline with Batchblock.Triggerbatch()

南楼画角 提交于 2019-12-24 11:50:35
问题 In my Producer-Consumer scenario, I have multiple consumers, and each of the consumers send an action to external hardware, which may take some time. My Pipeline looks somewhat like this: BatchBlock --> TransformBlock --> BufferBlock --> (Several) ActionBlocks I have assigned BoundedCapacity of my ActionBlocks to 1. What I want in theory is, I want to trigger the Batchblock to send a group of items to the Transformblock only when one of my Actionblocks are available for operation. Till then

Is there a TPL dataflow block that doesn't take input but returns output?

半城伤御伤魂 提交于 2019-12-23 22:01:31
问题 The title of my question says it all. I am looking for a TPL dataflow block that doesn't need an input. Right now I am using a transform block but it's input is unused. 回答1: I would build a block like this from a BufferBlock<T> : the method accepts a delegate that presents the ITargetBlock<T> side of the block and returns the ISourceBlock<T> side of it. This way, the delegate can send input to the block, but from the outside, it looks like a block that only produces output. The code: public

TPL Dataflow and exception handling in downstream blocks

耗尽温柔 提交于 2019-12-23 16:27:00
问题 I have the following pseudo code: var queue = new BufferBlock<int>(new DataflowBlockOptions { BoundedCapacity = 5 }); var a = new ActionBlock<int>(async item => { await Task.Delay(500); Trace.TraceInformation( $"Target 1: | Type: {typeof(int).Name} | Thread: {Thread.CurrentThread.ManagedThreadId} | Message: {item}"); // handling some logic but it throws if (item >= 5) throw new Exception("Something bad happened"); }, new ExecutionDataflowBlockOptions { BoundedCapacity = 1,