title: Do Events causing exception how to trace
body: <p><p> I have a code where Application.DoEvents is causing problems and throwing exceptions. When a modal popup is opened and application has to wait for user activity , this code is written to execute in a loop to process background tasks until user's activity . Can someone tell me how can I trace (in debugging) what process is called from DoEvents which causes exception .
  </p>
  <br /></p>
  
  <p>Here is some of the code . Can I trace what happens inside DoEvents :</p>
  
  <pre><code>private readonly AutoResetEvent Event = new AutoResetEvent(false);
  
   while (_Event .WaitOne(20, false) == false)
                  {
                      Application.DoEvents();
                      Thread.Sleep(0);
                  }
  </code></pre>