title: Task.Factory.StartNew - confused about the pool
body: <p>Hi I'm getting myself tied up with Task.Factory.StartNew. Just as I think I get the idea of it someone has suggested I write the following code;</p>
  
  <pre><code>bool exitLoop = false;                
  while (!exitLoop)
  {
      exitLoop = true;
      var messages = Queue.GetMessages(20);
      foreach (var message in messages)                    
      {
          exitLoop = false;
          Task.Factory.StartNew(() =&gt;
                      {
                          DeliverMessage(message);
                      });
      }
  }
  </code></pre>
  
  <p>In theory this is going to drain a queue, 20 messages at a time, attempting to creat a Task for every message in the queue. So if we had a 1000 messages in the queue then in an instant we'd have 25 tasks and it would eat its way through all the msgs. I previously thought I understood this, I thought StartNew would block once it ran out of entries - in the old days that would have been ~ 25. But given this is .net 4.5 which I'm now under the impression that the upper limit for a pool is now pretty high. What puzzles me is that I would have assumed that is going to flood the pool with new tasks and start blocking, i.e. in an instant I now have 1000 tasks running. So if the pool limit is now hardly a limit why am I not seeing 1000 tasks?</p>
  
  <p>[Edit]
  ok, so what I'm seeing is that 1000 tasks are queued to run, rather than are running. So how do I determine the number of running/runnable tasks?</p>