Sandor Heese <(E-Mail Removed)> wrote:
> When using BeginInvoke (on a From to marshal to the UI thread) with the
> EventHandler delegate I see some strange behaviour. The problem is that I
> call the UpdateTextBox method with a class derived from EventArgs ( i.e.
> MyEventArgs) and when the BeginInvoke is called and the UpdateTextBox
> methode is call on the UI thread the parameter e (EventArgs) does not
> contain the derived MyEventArgs object but a EventArgs object.
Yes - for some reason, if you call Invoke or BeginInvoke with an
EventHandler delegate, whatever parameters you supply will be ignored.
Bizarre, no?
It's documented for Invoke, but not BeginInvoke. Here's the docs for
Invoke:
<quote>
The 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. The delegate can also be an instance of
MethodInvoker, or any other delegate that takes a void parameter list.
A call to an EventHandler or MethodInvoker delegate will be faster than
a call to another type of delegate.
</quote>
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too