Ashutosh
Ashutosh

Reputation: 345

TaskScheduler for parallel Asyc Tasks

Feel free to ask for more context.

I have a requirement where a lot of tasks come and they can get in large number. So I want to throttle the queuing of tasks and want to control the concurrency also. Till now I have found that I can created a Custom TaskScheduler that limits the concurrency (I read here: http://msdn.microsoft.com/en-us/library/ee789351(v=vs.110).aspx) and also when tasks queued becomes more than a maximum limit I block the task scheduling in TaskFactory.StartNew method. Here are my questions:

  1. Is there a better advice to do this in a simple way please feel free to suggest.
  2. Also, in the implementation of LimitedConcurrencyLevelTaskScheduler I see that the implementation is using a ThreadPool underneath. Can I use something other than threadpool to schedule tasks? Doesn't extending the TaskScheduler gives the behavior of executing the in a threadpool and we jsut need to tell how to queue and dequeue tasks. Right?
  3. If we look at the Default TaskScheduler it uses the ThreadPool underneath as well. There are two things MaximumConcurrencyLevel and the thread count in ThreadPool. So if we set the MaximumConcurrencyLevel to integer. Then the concurrency level will depend on the threadpool count. How are the two related in default implementation. If the concurrency eventually depends on the threadpool count then what is the point of MaximumConcurrencyLevel used for in the framework?

Upvotes: 2

Views: 514

Answers (1)

Darek
Darek

Reputation: 4797

Have you considered any of the specialized task schedulers from parallel extensions extras?

http://blogs.msdn.com/b/pfxteam/archive/2010/04/09/9990424.aspx

Upvotes: 1

Related Questions