Control.Invoke Gotcha
I recently stumbled (of course) across an interesting wrinkle in Control.Invoke/BeginInvoke. From the fine print:
The [invoked] delegate can be an instance of EventHandler, in which case the sender parameter will contain this control, and the event parameter will contain EventArgs.Empty.
I dunno… While this seems to be done in order to preserve the notion of “sender” in an eventhandler, this strikes me as a somewhat shady clause to Invoke’s contract.



October 25th, 2005 at 3:42 pm
Fancy! I also saw in the docs you pointed to:
Hmm. Seems like for any other delegate type they will do a DynamicInvoke but that they’ve optimized here for these two “special” delegate types. WinForms performance mavens, take heed.