title: How to wait for background worker to finish processing?
body: <p>I have 3 background workers each processing a channel of a 24-bit Bitmap image (Y, Cb, Cr).  The processing for each 8-bit image takes several seconds and they might not complete at the same time.</p>
  
  <p>I want to merge the channels back into one image when I'm done.  When a button is clicked, each of the <code>backgroundWorkerN.RunWorkerAsync()</code> is started and when they complete I set a flag for true.  I tried using a while loop <code>while (!y &amp;&amp; !cb &amp;&amp; !cr) { }</code> to continually check the flags until they are true then exit loop and continue processing the code below which is the code to merge the channels back together.  But instead the process never ends when I run it.</p>
  
  <pre><code>   private void button1_Click(object sender, EventArgs e)
     {
          backgroundWorker1.RunWorkerAsync();
          backgroundWorker2.RunWorkerAsync();
          backgroundWorker3.RunWorkerAsync();
  
          while (!y &amp;&amp; !cb &amp;&amp; !cr) { }
  
          //Merge Code
     }
  </code></pre>