title: c# task multi-queue throttling
body: <p>I need a environment which needs to maintain different task queues, and for each of them to have a well defined number of concurrent threads that can execute for each queue. Something like this:</p>
  
  <ul>
  <li>Queue 1 -> 3 threads;</li>
  <li>Queue 2 -> 6 threads;</li>
  </ul>
  
  <p>Kind of Task system. I have managed to implement by myself this using plain old c# code (aka System.Threading.Thread, lock and queue) which works more than fine for 1+ year. However, I keep reading articles about the wonders of TaskFactory and TaskScheduler, about being possible this things with built-in classes in .NET, but I have failed to find an example to prove this. I would like to test it and to compare with what I have right now to see if it's working better and if it does, to replace it.</p>
  
  <p>More, I can live without having to limit/set the number of parallel threads for each queue as long as I can get the <code>guarantee</code> that if an item targeted for queue #2 is executed imediatly even if queue #1 is executing on full load.</p>
  
  <p>So, my question is - is there something in .net 4 and more, can someone point me to a sample? I am looking for one an entire week and failed to get something relevant.</p>