Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>1) Is it ever a good idea to call Application.DoEvents() inside a loop in order to keep the UI responsive while waiting for an async operation to complete before moving on to doing more work inside the same UI thread?</p> </blockquote> <p>Absolutely Not! <code>DoEvents()</code> is evil and will cause you all sorts of problems.</p> <blockquote> <p>2) Even if it's not a good idea to call Application.DoEvents() inside a loop, why does the application quietly exit (no window freezes, no error messages) after the catch clause handles the exception thrown by PerformAsyncOperation()?</p> </blockquote> <p>Difficult to say without knowing what <code>PerformAsyncOperation()</code> does. Unless it explicitly uses a new <code>Thread</code> ( or <code>Task</code> ), it will execute synchronously before your loop.</p> <p>As for the app exit - I can't explain that.</p> <p>If an uncaught exception is thrown on a worker <code>Thread</code>, the app will show the "stopped working" dialog box and exit.</p> <p>The only thing I know that has changed is the behaviour when an uncaught exception is thrown from inside a <code>Task</code>. Prior to .NET 4.5, this would cause a fast fail as with a <code>Thread</code>.</p> <p>If you have installed .NET 4.5 ( even if the app targets 4.0 ) an uncaught exception in a <code>Task</code> is now silently swallowed.</p> <p>Here's an article that explains the behaviours: <a href="http://blogs.msdn.com/b/pfxteam/archive/2011/09/28/10217876.aspx" rel="nofollow"><code>MSDN: Task Exception Handling in .NET 4.5</code></a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload