Do timers run on the same thread that creates them or (internally) a
new thread is spawned per timer? 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
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
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
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
|
|
| >
| >
| >
| > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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
|
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?
|
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...
|
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...
|
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...
|
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;...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |