|
-
May 8th, 2007, 04:11 AM
#1
Thread Starter
Frenzied Member
[Resolved][2005] Timer Question
This is really more of a general .Net Timer object question.
What happens if the code in the Tick method fails to complete before it's invoked again at the next tick? Are ticks queued and looped so that it will still maintain the timeframe?
Last edited by vbNeo; May 8th, 2007 at 05:47 AM.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
May 8th, 2007, 05:24 AM
#2
Re: [2005] Timer Question
Tick is an event, just like any other. They are raised on the UI thread and the UI thread can only do one thing at a time. If the UI thread is busy when the Tick event is raised then its handlers are not executed until the UI thread becomes available. This is true of all events. Tick is not in any way special in that regard. Now, if the previous Tick event handler is still executing when the next Tick event is raised then that would constitute the UI thread being busy.
-
May 8th, 2007, 05:46 AM
#3
Thread Starter
Frenzied Member
Re: [2005] Timer Question
 Originally Posted by jmcilhinney
Tick is an event, just like any other. They are raised on the UI thread and the UI thread can only do one thing at a time. If the UI thread is busy when the Tick event is raised then its handlers are not executed until the UI thread becomes available. This is true of all events. Tick is not in any way special in that regard. Now, if the previous Tick event handler is still executing when the next Tick event is raised then that would constitute the UI thread being busy.
I wasn't aware that Timers were part of the UI thread, I thought they had their own seperate one - but thanks for clarifying .
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
May 8th, 2007, 09:43 AM
#4
Re: [Resolved][2005] Timer Question
I'm starting to wonder whether anyone ever reads the MSDN documentation. From the System.Windows.Forms.Timer class topic:
A Timer is used to raise an event at user-defined intervals. This Windows timer is designed for a single-threaded environment where UI threads are used to perform processing. It requires that the user code have a UI message pump available and always operate from the same thread, or marshal the call onto another thread.
From the System.Timers.Timer class topic:
The server-based Timer is designed for use with worker threads in a multithreaded environment. Server timers can move among threads to handle the raised Elapsed event, resulting in more accuracy than Windows timers in raising the event on time.
...
If you use the Timer with a user-interface element, such as a form or control, assign the form or control that contains the Timer to the SynchronizingObject property, so that the event is marshaled to the user-interface thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|