Events executes in current thread or in a new one
When an event is raised does the handler exe开发者_Python百科cutes in the same thread as the main program or in another thread?.
Thanks !!
It gets executed on the thread that caused the event to occur.
Examples:
- User hits a button: GUI Thread.
- A background thread updates a property on an object: That background thread
- A WCF message is received: A thread from the thread pool
If you are doing GUI work this often means you need to marshall the event from the background thread to the GUI thread before touching any controls.
精彩评论