tags:

views:

23

answers:

1

When an event is raised does the handler executes in the same thread as the main program or in another thread?.

Thanks !!

+2  A: 

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.

Jonathan Allen
Ok, Get it !! thanks a lot !
carlos