By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

System.Timers.Timer and Daylight Savings

P: n/a
Is there any way to make a System.Timers.Timer adjust for daylight
savings time change? In a long running process I set a timer as follows
for a daily expiration:

_myTimer = new Timer(_myTimerDelegate, null, nextExpiration,
TimeSpan.FromDays(1));

When we make the change out of daylight time back to standard time, the
timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is
there a way to set this timer so that it is daylight-time aware?

Thanks

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This isn't a timer issue. The timer has no concept of the current time.
It only knows that in a ^span^ of time, it has to fire.

Because of this, you will have to check the timer period every time it
is fired, and determine if the next day will result in a shift in the time
because of daylight savings.

A better solution would be to use the Windows Scheduler to run this
task. It can be configured to run at a certain time each day, and is not
affected by daylight savings. Because the OS updates the time automatically
for daylight savings, the scheduler, which is based on the system time, will
work correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is there any way to make a System.Timers.Timer adjust for daylight
savings time change? In a long running process I set a timer as follows
for a daily expiration:

_myTimer = new Timer(_myTimerDelegate, null, nextExpiration,
TimeSpan.FromDays(1));

When we make the change out of daylight time back to standard time, the
timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is
there a way to set this timer so that it is daylight-time aware?

Thanks

Nov 17 '05 #2

P: n/a
Thanks, that's what I thought. This function is actually sending a
message periodically from a long running process, so the Scheduler
would probably not be an option. It's too bad there's not an option on
the Timer to adjust for daylight changes, ie increment/decrement the
span when it crosses a daylight boundary.

Nov 17 '05 #3

P: n/a
What is stopping you from stopping the timer and creating a new instance
with the correct time span?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Thanks, that's what I thought. This function is actually sending a
message periodically from a long running process, so the Scheduler
would probably not be an option. It's too bad there's not an option on
the Timer to adjust for daylight changes, ie increment/decrement the
span when it crosses a daylight boundary.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.