Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Which events' event handlers are BeginInvoke'd rather than called directly?

$
0
0

Is there a list of which WinForms Events have the handling of their events BeginInvoke'd to be processed at some later point rather than being called directly?

For example, it helped us tremendously when we discovered that the Shown event handlers would be BeginInvoke'd for later processing rather than directly called like the Load event and the Activate event.

Why does that help us?  

First, because you can't assume in the line after the Show() call that the Shown event handlers will have run... they will have been queued up, but they may not have run yet.  Whereas you can rely on the Load and Activate handlers having run.

Second, and more importantly, you absolutely cannot throw Exceptions out of event handlers that are queued up via BeginInvoke()... the exceptions they throw will NOT be caught by the try-catch's that are outside the Show() call.  The Shown event handler will be invoked by the top level application message pump... and you never ever want to throw out of the top level application message pump.

Soooo, knowing which event handlers are BeginInvoke'd is pretty much essential to writing reliable WinForms code.  And yet, as best I can tell, Microsoft hasn't documented how each Event's handlers are invoked.

Hence, my question here.  Has anyone compiled a list of such?  Or is there some way to find out without looking through the WinForms code, examining each BeginInvoke or examining each Event invocation?

Thanks for any pointers!


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>