Home All Groups Group Topic Archive Search About

Timers run on the creating thread?

Author
11 Jul 2006 9:13 AM
Water Cooler v2
Do timers run on the same thread that creates them or (internally) a
new thread is spawned per timer?

Author
11 Jul 2006 10:17 AM
Damien
Water Cooler v2 wrote:
> 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
Author
12 Jul 2006 2:17 AM
Michael D. Ober
The System.Threading timer events are executed from a Thread Pool thread.

Mike Ober.

Show quote
"Damien" <Damien_The_Unbelie***@hotmail.com> wrote in message
news:1152613059.725941.34710@s13g2000cwa.googlegroups.com...
> Water Cooler v2 wrote:
> > 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
>
>
Author
13 Jul 2006 11:39 PM
Dennis
Which thread will receive the event then for the System.Threading timer.
--
Dennis in Houston


Show quote
"Michael D. Ober" wrote:

> The System.Threading timer events are executed from a Thread Pool thread.
>
> Mike Ober.
>
> "Damien" <Damien_The_Unbelie***@hotmail.com> wrote in message
> news:1152613059.725941.34710@s13g2000cwa.googlegroups.com...
> > Water Cooler v2 wrote:
> > > 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
> >
> >
>
>
>
>
Author
14 Jul 2006 12:52 AM
William Stacey [MVP]
The callback is run on a ThreadPool thread.  What event are you referring
to?  tia

--
William Stacey [MVP]

Show quote
"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:1F70A605-8E21-432B-83D0-497012D52AD7@microsoft.com...
| Which thread will receive the event then for the System.Threading timer.
| --
| Dennis in Houston
|
|
| "Michael D. Ober" wrote:
|
| > The System.Threading timer events are executed from a Thread Pool
thread.
| >
| > Mike Ober.
| >
| > "Damien" <Damien_The_Unbelie***@hotmail.com> wrote in message
| > news:1152613059.725941.34710@s13g2000cwa.googlegroups.com...
| > > Water Cooler v2 wrote:
| > > > 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
| > >
| > >
| >
| >
| >
| >

AddThis Social Bookmark Button