title: ManualResetEvent with a BackgroundWorker : Current thread is busy while WaitOne()?
body: <p>Imagine following situation:</p>
  
  <ol>
  <li><p>I got a signal on the ui thread from a third party server. </p></li>
  <li><p>I start a BackgroundWorker with RunAsync to fetch data from a database and another async thread, which shall poll
  another hardware and receive signals, also not in ui thread</p></li>
  <li><p>Inside the bg's  DoWork eventhandler I call manualresetEvent.Reset(). Then I call the data-fetching method, and then I call manualresetEvent.Set() and in the end I call the method METH_UI_1 on the ui thread by invoking it.</p></li>
  <li><p>The other hardware thread shall receive hardware-data, which then itself is passed via Invoke to the ui into the ui thread to set some ui-elements periodically depending on the hardware-data I get.</p></li>
  <li><p>The data from database can also not be fetched yet, but the ui must react to the hardware-data, which is polled by the second async thread.</p></li>
  <li><p>In METH_UI_1 I call manualresetEvent.WaitOne();</p></li>
  </ol>
  
  <p>Some times I get the exception, that the background worker is busy and cannot run multiple tasks concurrently.</p>
  
  <p>a) Is there really a need for a ManualResetEvent object ?</p>
  
  <p>b) Would it be enough, to check for the isBusy property in order to issue WaitOne() only, when the background worker is no more busy ?</p>
  
  <hr>
  
  <p>UPDATE: CODE.</p>
  
  <p>MainForm.cs (event handler of third party hw-vendor, component, handled in ui thread)</p>
  
  <pre><code> private void thrdptyPlcGotData(object sender, thrdptyPlcGotDataEventArgs e)
      {
          string strError = string.Empty;
          bool blNotReadyYet = false;            
  
          try
          {
              ThrdPtyPlcIfs.DataSetthrdptyPlc ds;
  
                  ds = new ThrdPtyPlcIfs.Dataset();
                  e.FillDataToTDataSet(ds);
                 ThrdPtyPlcIfs.Statics.SaveDataSet(ds, CLStatics.FileName);
  
  
                                 if (this.ValidateDsDetail(ds))
                                  {
                                      // begin async work..... ask db, continue asking scale-&gt; inside got weight of scale the rest is handled ( using or trashing db data )
                                      this.ExtractDataOfDataSet(ds);
                                      this.bgWorkerStart_Get_Data.RunWorkerAsync();                                        
  
                                      _oAsyncScaleManager.StartThread();
                                   }
           }
  }
  </code></pre>
  
  <p>runworkerasynch does this:</p>
  
  <pre><code>private void bgWorkerStart_Get_Data_RFC_DoWork(object sender, DoWorkEventArgs e)
      {
          try
          {
  
              _blnStart_Get_Data_RFC = this.StartGetData_RFC(null);
          }
          catch (Exception ex)
          {
              LogExcep(ex);
              _blnStart_Get_Data_RFC = false;
          }            
      }
  </code></pre>
  
  <p>WorkCompleted EventHandler of the BackGroundWorker:</p>
  
  <pre><code> private void bgWorkerStart_Get_Data_RFC_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {            
          try
          {  
              if (InvokeRequired)
              {
                  this.Invoke((MethodInvoker)delegate()
                  {
                      this.ApplyDbDataToUi();
                  }
                              );
              }
              else
              {
                  this.ApplyDbDataToUi();
              }
  
          }
          catch (Exception ex)
          {
              LogAndShowExep(ex);
          }
      }
  </code></pre>