title: WaitHandle.WaitAll and ManualResetEvent.Set() - what should be first?
body: <p>I have a question about working of WaitHandle.WaitAll, and would appreciate any help.</p>
  
  <p>Let's assume I have such situation: the Parent thread is opening couple of Child Threads and must wait with 'doing other stuff' until child threads finish their work.</p>
  
  <p>I use WaitHandle.WaitAll and would like to stay with this method. (NO Thread.Join etc, please :) )</p>
  
  <pre><code>ManualResetEvent[] events = new ManualResetEvent[list.Count];
  
  foreach (string row in list)
  {
      events[i] = new ManualResetEvent(false);                
  
      Thread thread = new Thread(new ParameterizedThreadStart(DoSomething));
      thread.Start(events[i]); // start child thread
  
      System.Threading.Thread.Sleep(1000000);
  
      i++;
  }
  
  WaitHandle.WaitAll(events); // wait for child threads finish their work
  ...
  ...
  
  
  private DoSomething(object sth)
  {
  // some stuff that executes only 1 second
  ManualResetEvent.Set()
  }
  </code></pre>
  
  <p>So situation for the first newly started child-thread would be that the calling of ManualResetEvent.Set() is BEFORE calling WaitHandle.WaitAll(events) in the Parent thread. Because loop which opens new child threads has some long timeout.</p>
  
  <p><strong>So my question, wouldn't be such time-line a problem?
  Shouldn't be WaitHandle.WaitAll called before calling the ManualResetEvent.Set()?</strong></p>