c# - Structuring Task Processing Pipeline with the Task Parallel Library -


i come objective-c background, use grand central dispatch or nsoperations solve problem trivially. unfortunately think i'm stuck in way of thinking when trying structure problem in c#.

i have high-level tasks, each of have multiple parts can happen in parallel. each of these parts need go through several stages in pipeline. need construct pipeline, know when high-level task completes, , execute callback.

with gcd, create queues perform parts on, each chaining next part of process. of these parts grouped based on high level task part of, callback triggered @ end.

i'm struggling work out how work in c#. i've been researching task parallel library, have no particular preference use. 1 issue have run far completion callbacks seem possible tpl pipelines if finish processing, have multiple tasks wouldn't happen.

at overview sort of level, how problem best structured? wonder if might better write system rx providing concurrency?

i don't quite understand mean completion callbacks not being option due having multiple tasks. constructing dataflow network each task mean completion triggered them individually.

i'm guessing want avoid overhead resulting reconstructing network each time? in case, maybe add passthrough block of sorts @ end: returns whatever input it's given, , calls whatever callback need. each output produced network, callback invoked. if want take step further, instead post message block, can invoke callbacks in parallel.

alternatively, if pipeline simple enough, , don't need buffering , whatnot, maybe plain tpl tasks? this:

public async task<string> highleveltask(string input1, string input2, action completed) {     task<string[]> parts = task.whenall(part1(input1), part2(input2));     string[] results = await parts;     completed();     return string.join(",", results); } public async task<string> part1(string input) {     var result1 = await stage1(input);     var result2 = await stage2(result1);     return result2; } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -