473,394 Members | 1,769 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,394 software developers and data experts.

about System.Threading.Timer interval

hi
When I set up a timer in my program, I used public
Timer(TimerCallback, object, TimeSpan, TimeSpan)
constructor. I want the timer to fire after a mount of
time, so I wrote "new Timer(new TimeCallback
(some_function), null, timeDiff, new TimeSpan)".When I
ran the program, VS.NET popped a MsgBox that told me the
timer interval must be less than 2^32-2.Actually, the
argument "timeDiff" could be very large(maybe 2 or 3
years).How can I dealing with this problem?

thanks
violin

Nov 22 '05 #1
5 2323
violin wang <an*******@discussions.microsoft.com> wrote:
When I set up a timer in my program, I used public
Timer(TimerCallback, object, TimeSpan, TimeSpan)
constructor. I want the timer to fire after a mount of
time, so I wrote "new Timer(new TimeCallback
(some_function), null, timeDiff, new TimeSpan)".When I
ran the program, VS.NET popped a MsgBox that told me the
timer interval must be less than 2^32-2.Actually, the
argument "timeDiff" could be very large(maybe 2 or 3
years).How can I dealing with this problem?


I'd suggest having a timer which actually fired once a day, only going
for the "accurate" real firing time when it was less than a day away.
That way there'd be less chance of missing the correct time due to
clock changes, time resynchronization etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
"violin wang" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
When I set up a timer in my program, I used public
Timer(TimerCallback, object, TimeSpan, TimeSpan)
constructor. I want the timer to fire after a mount of
time, so I wrote "new Timer(new TimeCallback
(some_function), null, timeDiff, new TimeSpan)".When I
ran the program, VS.NET popped a MsgBox that told me the
timer interval must be less than 2^32-2.Actually, the
argument "timeDiff" could be very large(maybe 2 or 3
years).How can I dealing with this problem?


There's a different Timer() constructor that takes 64-bit values. You can
use that instead of TimeSpan.

http://msdn.microsoft.com/library/en...ctortopic2.asp

-- Alan
Nov 22 '05 #3
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
I'd suggest having a timer which actually fired once a day, only going
for the "accurate" real firing time when it was less than a day away.
That way there'd be less chance of missing the correct time due to
clock changes, time resynchronization etc.


It's doubtful the computer will even be up and running that long anyway
without needing to be rebooted... Every Windows Update makes you reboot.

-- Alan
Nov 22 '05 #4
Alan Pretre <no@spam> wrote:
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
I'd suggest having a timer which actually fired once a day, only going
for the "accurate" real firing time when it was less than a day away.
That way there'd be less chance of missing the correct time due to
clock changes, time resynchronization etc.


It's doubtful the computer will even be up and running that long anyway
without needing to be rebooted... Every Windows Update makes you reboot.


That was my feeling as well, but maybe the OP has some special set of
circumstances :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #5
-----Original Message-----
violin wang <an*******@discussions.microsoft.com> wrote:
When I set up a timer in my program, I used public
Timer(TimerCallback, object, TimeSpan, TimeSpan)
constructor. I want the timer to fire after a mount of
time, so I wrote "new Timer(new TimeCallback
(some_function), null, timeDiff, new TimeSpan)".When I
ran the program, VS.NET popped a MsgBox that told me the timer interval must be less than 2^32-2.Actually, the
argument "timeDiff" could be very large(maybe 2 or 3
years).How can I dealing with this problem?
I'd suggest having a timer which actually fired once a

day, only goingfor the "accurate" real firing time when it was less than a day away.That way there'd be less chance of missing the correct time due toclock changes, time resynchronization etc.
Thank you very much.--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 22 '05 #6

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

Similar topics

0
by: violin wang | last post by:
hi When I set up a timer in my program, I used public Timer(TimerCallback, object, TimeSpan, TimeSpan) constructor. I want the timer to fire after a mount of time, so I wrote "new Timer(new...
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...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
3
by: Andy | last post by:
Hello. I want to use System.Threading.Timer to control when my windows form is invalidated. I want it to update at 60 frames per second. But, if I set the Interval of my timer to anything less than...
1
by: Can Balioglu | last post by:
Hi, I don't know if it's already known but I found a bug in System.Timers.Timer class. The 'Interval' property accepts a double which specifies the interval between two 'Elapsed' events. The...
1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
2
by: linesh.gajera | last post by:
Hi Guys, I am creating a Windows service that call a routine at given interval. Once routine is complete, windows service should wait for 5 minutes and then call the routine again. I was using...
2
by: User | last post by:
Hi, What is the best way to release all resources holded by the Timer (myTimer from class System.Timers.Timer)? Is it: 1- myTimer.dispose 2- myTimer.enabled = false 3- myTimer.close
9
by: archana | last post by:
Hi all, I want to know about interval of timer. I am using timer in windows service.I head somewhere that when i set interval property of timer while setting interval, restart time of Pc is...
4
by: Lauren Quantrell | last post by:
I have just put together a vb.net app and now need to provide it to users. This application needs to run the code in a sub every 60 seconds from a Windows Service application. I have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.