title: System.Threading.Tasks - Limit the number of concurrent Tasks
body: <p>I have just started to look at the new "System.Threading.Tasks" goodness in .Net 4.0, and would like to know if there is any build in support for limiting the number of concurrent tasks that run at once, or if this should be manually handled.</p>
  
  <p>E.G: If I need to call a calculation method 100 times, is there a way to set up 100 Tasks, but have only 5 execute simultaneously? The answer may just be to create 5 tasks, call Task.WaitAny, and create a new Task as each previous one finishes. I just want to make sure I am not missing a trick if there is a better way to do this.</p>
  
  <p>Basically, is there a built in way to do this:</p>
  
  <pre><code>Dim taskArray() = {New Task(Function() DoComputation1()),
                     New Task(Function() DoComputation2()),
                     ...
                     New Task(Function() DoComputation100())}
  
  Dim maxConcurrentThreads As Integer = 5
  RunAllTasks(taskArray, maxConcurrentThreads)
  </code></pre>
  
  <p>Thanks for any help.</p>