473,385 Members | 1,492 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,385 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 1425
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;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.