KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to queue dependant tasks across several flows that need to be processed in order (in each flow). The flows can be processed in parallel. To be specific, let's say I need two queues and I want the tasks in each queue to be processed in order. Here is sample pseudocode to illustrate the desired behavior: Queue1_WorkItem wi1a=...; enqueue wi1a; ... time passes ... Queue1_WorkItem wi1b=...; enqueue wi1b; // This must be processed after processing of item wi1a is complete ... time passes ... Queue2_WorkItem wi2a=...; enqueue wi2a; // This can be processed concurrently with the wi1a/wi1b ... time passes ... Queue1_WorkItem wi1c=...; enqueue wi1c; // This must be processed after processing of item wi1b is complete Here is a diagram with arrows illustrating dependencies between work items: The question is how do I do this using C# 4.0/.NET 4.0? Right now I have two worker threads, one per queue and I use a BlockingCollection<> for each queue. I would like to instead leverage the .NET thread pool and have worker threads process items concurrently (across flows), but serially within a flow. In other words I would like to be able to indicate that for example wi1b depends on completion of wi1a, without having to track completion and remember wi1a, when wi1b arrives. In other words, I just want to say, "I want to submit a work item for queue1, which is to be processed serially with other items I have already submitted for queue1, but possibly in parallel with work items submitted to other queues". I hope this description made sense. If not please feel free to ask questions in the comments and I will update this question accordingly. Thanks for reading. Update: To summarize "flawed" solutions so far, here are the solutions from the answers section that I ca
Tags (comma-separated)
Save Edits
Cancel