Do events in C # fire the current thread execution?

If I fire the event:

var handler = OnMyEvent; if (handler != null) { handler(some_info); } 

then the execution thread will wait until all the binder methods return to continue execution after the line:

 handler(some_info); 

?

Or events are triggered "in another thread", which means that it automatically moves to the next line after handler(some_info) ?

+4
source share
2 answers

Events are triggered in a single thread and blocked until they are completed. Of course, the event processing code itself may spawn a different thread and return immediately, but this is a completely different matter.

Also note that events, such as button presses in desktop applications such as Windows Forms applications, are placed in the message queue and will be fired one at a time. those. if you press a button and then press another button, the event of the second button will not fire until the first is completed. Also, the form will not be redrawn and will not respond, because painting the form is also an event.

+10
source

Events are excited in the stream that raised them.

+2
source

All Articles