473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Timers run on the creating thread?

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

Jul 11 '06 #1
4 881
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

Jul 11 '06 #2
The System.Threading timer events are executed from a Thread Pool thread.

Mike Ober.

"Damien" <Da*******************@hotmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.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



Jul 12 '06 #3
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" <Da*******************@hotmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.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

Jul 13 '06 #4
The callback is run on a ThreadPool thread. What event are you referring
to? tia

--
William Stacey [MVP]

"Dennis" <De****@discussions.microsoft.comwrote in message
news:1F**********************************@microsof t.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" <Da*******************@hotmail.comwrote in message
| news:11*********************@s13g2000cwa.googlegro ups.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
|
|
| >
| >
| >
| >
Jul 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
1
by: Jason | last post by:
Hi all just a quick question. I have a windows service with a "Catalogue" class. I would like to know: if i put two "ServiceTimer" objects in my service 1. Do they run in separate threads...
9
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
3
by: Maarten | last post by:
Hi In my aplication it seems that my timer slows down everything, is there a better and/or diferent way than using a timer Maarten
4
by: Water Cooler v2 | last post by:
Do timers run on the same thread that creates them or (internally) a new thread is spawned per timer?
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
0
by: simplediscourse | last post by:
i'm trying to demonstrate timeslicing among equal high priority threads without putting threads to sleep. to do this i'm trying to run a timer while executing a very long loop sequence in order to...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
1
by: =?Utf-8?B?QnNtZW5nZW4=?= | last post by:
I create the timer like this: StreamingTimer = new System.Timers.Timer(); StreamingTimer.Elapsed += new System.Timers.ElapsedEventHandler(StreamingProc); StreamingTimer.Interval = 1000;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.