Reputation: 4885
Are public events asynchronous? Do they execute on a separate thread?
Upvotes: 1
Views: 748
Reputation: 15785
They are executed in whatever thread the event is triggered by.
This means, if the event is raised by the GUI thread, the event handler's for that event are executed in the GUI's thread. If the event is raise by some background thread, the event handlers are executed in that background thread. Within whatever thread the handler is executing, the method is executed synchronously.
As an additional note, if you have an event handler in a form, for an event that raised by a class that is working in the background, when that event is trigger, the event handler will be called in the background thread. Which means, you will need to use Control.Invoke or some other mechanism to properly pass data into the GUI thread, so that the form can be modified.
Upvotes: 3
Reputation:
NO they are not asynchronous and they are executed on the same thread that invoked them.
Upvotes: 0