Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Parallel Task Queues in .Net

An image speaks more than words, so here is basically what I want to achieve :
(I have also used a fruit analogy for the sake of genericity an simplicity)
enter image description here

I've done this kind of stuff many time in the past using different king of .Net classes (BackGroundWOrkers, ThreadPool, Self Made Stuff...)

I am asking here for the sake of advice and to get fresh ideas on how to do this efficiently.
This is a high computing program so I am receiving Millions of (similar in structure but not in content) data, that have to be queued in order to be processed according to its content type. Hence, I want to avoid creating a parallel task for each single data to be processed (this overloads the CPU and is poor design IMHO). That's why I got the idea of having only ONE thread running for EACH data TYPE, dedicated to processing it (knowing that the "Press Juice" method is generic and independent of the fruit to be pressed)

Any Ideas and implementation suggestions are welcome.
I am free to give any further details.

like image 783
Mehdi LAMRANI Avatar asked Jan 08 '13 10:01

Mehdi LAMRANI


People also ask

Do tasks run in parallel C#?

NET Core, C# and async coding. If you have several tasks that can be run in parallel, but still need to wait for all the tasks to end, you can easily achieve this using the Task. WhenAll() method in .

What is Task Parallel Library in C#?

The Task Parallel Library (TPL) is a set of public types and APIs in the System. Threading and System. Threading. Tasks namespaces. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications.

How do you do parallel tasks?

Parallel tasks are split into subtasks that are assigned to multiple workers and then completed simultaneously. A worker system can carry out both parallel and concurrent tasks by working on multiple tasks at the same time while also breaking down each task into sub-tasks that are executed simultaneously.


1 Answers

TPL DataFlow seems like a very strong candidate for this.

Take a read of the intro here.

like image 176
spender Avatar answered Oct 02 '22 15:10

spender