Lets say I have a Timer which has the Elapsed event handled. What thread is the method code executed on?
Is is the thread that the timer was created on? If so, that means if I wish it to be on another thread I have to ensure that the timer gets created in the threads main loop rather than the initialization of the thread – correct?
The thread is one out of the threadpool. There is no way to prodict which thread will be associated with the elapsed method.
Details: http://msdn.microsoft.com/en-us/library/system.timers.timer.elapsed.aspx
(And it should not matter, from a designs perspective)
Edit: Actually there is a method to define which thread is used; You can used the SynchronizingObject property of the timer:
See: http://msdn.microsoft.com/en-us/library/system.timers.timer.synchronizingobject.aspx