title: How to "kill" background worker completely?
body: <p>I am writing a windows application that runs a sequence of digital IO actions repeatedly.</p>
  
  <p>This sequence of actions starts when the user click a "START" button, and it is done by a background worker in backgroundWorker1_DoWork().</p>
  
  <p>However, there are occasions when I get the "This backgroundworker is currently busy......." error message.</p>
  
  <p>I am thinking of implementing the following in the code, by using a while loop to "kill" the background worker before starting another sequence of action:</p>
  
  <pre><code>if (backgroundWorker1.IsBusy == true)
  {
  
      backgroundWorker1.CancelAsync();
      while (backgroundWorker1.IsBusy == true)
      {
          backgroundWorker1.CancelAsync();
      }
  
      backgroundWorker1.Dispose();
  
  }
  
  backgroundWorker1.RunWorkerAsync();
  </code></pre>
  
  <p>I think my main concern is, will the backgroundWorker1 be "killed" eventually? If it will, will it take a long time to complete it?</p>
  
  <p>Will this coding get me into an infinite loop?</p>