title: RunWorkerAsync close BackgroundWorker on complete
body: <p>I have a Background worker that needs to be called multiple times based on the number of checkboxes checked - I have written this to get the checkbox values and put them into a <code>List</code>.</p>
  
  <pre><code>List repSelected = new List();</code></pre>
  
  <p>This is populated and then iterated over like so:</p>
  
  <pre><code>foreach (string rep in repSelected)
  {
      backgroundWorker1.RunWorkerAsync(rep);
      backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
  }</code></pre>
  
  <p>The async, DoWork code looks like this:</p>
  
  <pre><code>BackgroundWorker worker = sender as BackgroundWorker;
  string rep = e.Argument.ToString();
  
  if (worker.CancellationPending == true)
  {
      e.Cancel = true;
  }
  else
  {
      DirectoryExists(rep);
      ProcessRunner(rep); //Rars some large files - expensive
  }</code></pre>
  
  <p>The process then runs WorkerComplete, the problem is when the process goes back to do the next iteration of the Worker it crashes out saying the worker is busy - even though the worker has returned it's WorkerCompleted status.</p>
  
  <p>How can I make sure that the thread is closed before the next iteration of the loop?</p>
  
  <p>NB: I had a conditional on the background worker containing <code>!backgroundWorker1.IsBusy()</code> but this (obviously) just skipped over the remaining iterations without execution.</p>