Timers run on the creating thread?

  • Thread starter Thread starter Water Cooler v2
  • Start date Start date
W

Water Cooler v2

Do timers run on the same thread that creates them or (internally) a
new thread is spawned per timer?
 
Water said:
Do timers run on the same thread that creates them or (internally) a
new thread is spawned per timer?

It depends on which Timer you are referring to. If it is the Timer
within System.Windows.Forms, then it'll run on the UI thread. If it's
the Timer within System.Threading, then I believe it runs in another
thread. Whether this thread is newly created, or from the thread pool,
or from some internal pool, I'm not sure. But I'm fairly certain it
won't be the original thread. After all, the original thread has
carried on, and could be in any state when the timer elapses (e.g. it
might be in the middle of a multi-second database call)

Damien
 
The System.Threading timer events are executed from a Thread Pool thread.

Mike Ober.
 
Back
Top