Wednesday 15 July 2015

.net - Continue tasks when current task is completed -


I have 25 works created in the list. I can fire only 10 threads on time.

I need to start one of my lists and start the first 10 tasks using TPL. Until then I would like to wait till no work is completed. If any work is done then I have to continue my focus loop and start my 11th work. Similarly, I have to do all for 25 works in my list.

Any recommendations?

This is a common requirement. The correct solution is not included in the .NET Framework, a good way to do this. To create a cover for all those tasks that are waiting for a semaphorcil , the semaphore will implement the limit of your desired concurrency. After waiting for it, you can start the real work which can start ans.

This solution can be easily achieved through built-in tools, but the disadvantage is that you have to start all 25 tasks once. So you can not process a very large or infinite stream of objects with this technique. There is no problem in your case.

No comments:

Post a Comment