If I set up multiple event handlers, like so:
_webservice.RetrieveDataCompleted += ProcessData1; _webservice.RetrieveDataCompleted += ProcessData2;
what order are the handlers run when the event RetrieveDataCompleted
is fired? Are they run in the same thread and sequentially in the order that are registered?
1) Currently they are executed in the order that the implementation of the specific event dictates - since you can implement your own add/remove methods for events. 2) When using the default event implementation via multi-cast delegates, the order is in fact required by specifications.
Event capturing the event handler of element1 fires first, the event handler of element2 fires last.
An event handler, in C#, is a method that contains the code that gets executed in response to a specific event that occurs in an application. Event handlers are used in graphical user interface (GUI) applications to handle events such as button clicks and menu selections, raised by controls in the user interface.
Event handler code can be made to run when an event is triggered by assigning it to the target element's corresponding onevent property, or by registering the handler as a listener for the element using the addEventListener() method.
Currently, they are executed in the order they are registered. However, this is an implementation detail, and I would not rely on this behavior staying the same in future versions, since it is not required by specifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With