title: Too many Tasks causes SQL db to timeout
body: <p>My problem is that I'm apparently using too many tasks (threads?) that call a method that queries a SQL Server 2008 database. Here is the code:</p>
  
  <pre><code>for(int i = 0; i &lt; 100000 ; i++)
  {  
    Task.Factory.StartNew(() =&gt; MethodThatQueriesDataBase()).ContinueWith(t=&gt;OtherMethod(t));  
  }
  </code></pre>
  
  <p>After a while I get a SQL timeout exception. I want keep the actual number of threads low(er) than 100000 to a buffer of say "no more than 10 at a time". I know I can manage my own threads using the ThreadPool, but I want to be able to use the beauty of TPL with the <strong><em>ContinueWith</em></strong>.   </p>
  
  <p>I looked at the <code>Task.Factory.Scheduler.MaximumConcurrencyLevel</code> but it has no setter.  </p>
  
  <p>How do I do that?</p>
  
  <p>Thanks in advance! </p>
  
  <p><strong>UPDATE 1</strong><br>
  I just tested the <code>LimitedConcurrencyLevelTaskScheduler</code> class (pointed out by Skeet) and still doing the same thing (SQL Timeout).<br>
  BTW, this database receives more than 800000 events per day and has never had crashes or timeouts from those. It sounds kinda weird that this will.</p>