Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can threads started by Tasks Parallel Library act as foreground threads?

MSDN documentation indicates that threads started by the TPL will enjoy better scheduling. However, since the threads are based upon ThreadPool, they will be implemented as background threads.

Now, there are some tasks I would like to be carried out in parallel, but it is imperative that these tasks be carried out until completion.

So, how do I create such tasks that are essentially foreground threads, but still enjoy the enhanced scheduling provided by the TPL?

like image 360
pepoluan Avatar asked May 27 '11 19:05

pepoluan


1 Answers

You could write your own TaskScheduler implementation. Have a look in the TaskScheduler documentation for an example of implementing a TaskScheduler - hopefully it's relatively simple from there.

like image 80
Jon Skeet Avatar answered Oct 21 '22 17:10

Jon Skeet