title: ManualResetEvent and Task Issue
body: <p>I've been working on a custom multi-threaded server that uses HTTP to communicate with clients.  To create new threads, I've been using the Task.Factory.StartNew() method. For synchronization, I've been using ManualResetEvent objects.</p>
  
  <p>Here's the essence of the code:</p>
  
  <pre><code>namespace ThreadTest {
      class Program {        
          private readonly ManualResetEvent _event = new ManualResetEvent(false);
  
          public void Start() {
              for (int i = 0; i &lt; 100; i++) {
                  int num = i;
                  Task.Factory.StartNew(() =&gt; {
                      Console.WriteLine("Task {0} Started", num);
                      _event.WaitOne();
                  });
              }  
          }      
  
          static void Main(string[] args) {
              var test = new Program();
              test.Start();
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>In the real code, the <code>_event</code> object would eventually have <code>Set</code> called on it to release the waiting tasks.</p>
  
  <p>The problem I've run into is that this code works fine on my development machine (which is dual-core with 2 threads per core and using the MS .NET 4 runtime) but does not work on my server (which is single core with 1 thread per core and using the Mono 2.8 runtime).  The output on my development machine is:</p>
  
  <pre><code>Task 0 Started
  Task 1 Started
  Task 3 Started
  Task 2 Started
  Task 4 Started
  Task 5 Started
  ...
  </code></pre>
  
  <p>While the server output is</p>
  
  <pre><code>Task 53 Started
  </code></pre>
  
  <p>My question is: What am I misunderstanding about the ManualResetEvent or Tasks?  Why does the TaskFactory continue to make tasks on the dual-core but not the single-core?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I just tried it on my dual-core (1 thread per core) mac laptop and I got the output</p>
  
  <pre><code>Task 97 Started
  Task 1 Started
  </code></pre>
  
  <p>And then nothing.  I also tried it with Mono on my development machine (4 threads) and got:</p>
  
  <pre><code>Task 99 Started
  Task 2 Started
  Task 98 Started
  Task 0 Started
  </code></pre>
  
  <p>So it looks like a bug with Mono.</p>