Reputation: 931
I am get confused with the following code.
someObject
.Dispatcher
.BeginInvoke(new SomeDelegate(SomeEvent), SomeParamater);
here SomeDelegate is a delegate, SomeEvent is an event of class.
When I am running the code, SomeEvent is fired and the event handler gets the control.
Can some one explain how it is running?
Upvotes: 1
Views: 4491
Reputation: 128013
The question was: how to invoke an event defined as
public event EventHandler<SomeEventArgs> SomeEvent;
via Dispatcher.BeginInvoke
?
It is done like this:
Dispatcher.BeginInvoke(new EventHandler<SomeEventArgs>(SomeEvent), this, new SomeEventArgs());
or any other value instead of this
as second argument, wich gets passed to the event handler as the sender
argument.
Upvotes: 2