Problem with Timer
-
Hi All, I am using timer in one of the application I am developing. When I try to set the interval to "2233860000.0 millisec", I am getting the following exception "Number must be either non-negative or -1.\r\nParameter name: dueTime" Here is the code snippet I am using System.Timers.Timer timerTest = new System.Timers.Timer(); timerTest.Interval = 2200920000.0; timerTest.Enabled = true; timerTest.Start(); timerTest.Elapsed +=new System.Timers.ElapsedEventHandler(time_Elapsed); Thanks in Advance, Jo
-
Hi All, I am using timer in one of the application I am developing. When I try to set the interval to "2233860000.0 millisec", I am getting the following exception "Number must be either non-negative or -1.\r\nParameter name: dueTime" Here is the code snippet I am using System.Timers.Timer timerTest = new System.Timers.Timer(); timerTest.Interval = 2200920000.0; timerTest.Enabled = true; timerTest.Start(); timerTest.Elapsed +=new System.Timers.ElapsedEventHandler(time_Elapsed); Thanks in Advance, Jo
too big for a 32-bit integer. OTOH do you really expect this program to run 25 days uninterupted? top secret
Download xacc-ide 0.0.3 now!
See some screenshots -
too big for a 32-bit integer. OTOH do you really expect this program to run 25 days uninterupted? top secret
Download xacc-ide 0.0.3 now!
See some screenshotstimer.Interval is double not 32 bit integer
-
timer.Interval is double not 32 bit integer
You are wrong. It is Int32.
-
You are wrong. It is Int32.
-
Hi All, I am using timer in one of the application I am developing. When I try to set the interval to "2233860000.0 millisec", I am getting the following exception "Number must be either non-negative or -1.\r\nParameter name: dueTime" Here is the code snippet I am using System.Timers.Timer timerTest = new System.Timers.Timer(); timerTest.Interval = 2200920000.0; timerTest.Enabled = true; timerTest.Start(); timerTest.Elapsed +=new System.Timers.ElapsedEventHandler(time_Elapsed); Thanks in Advance, Jo
It should work, but I don't have VS.NET in front of me to play around with it. Also, the other comments about having this fire 25 days later are correct. It's just not practical to assume that your code is going to be running constantly for a month straight. What are you doing with this code? There are FAR more accurate and easily implemented methods to getting a time based event running on such a long period schedule. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Oh, I have to admit I didnt read carefully enough. I thought he meant System.Windows.Forms.Timer. I couldnt reproduce the problem. The code works fine in my sample project.
-
It should work, but I don't have VS.NET in front of me to play around with it. Also, the other comments about having this fire 25 days later are correct. It's just not practical to assume that your code is going to be running constantly for a month straight. What are you doing with this code? There are FAR more accurate and easily implemented methods to getting a time based event running on such a long period schedule. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
I am using this in a windows service. If the users dosen't shutdown the system for a longer period. I required my timer to schedule to a desired time.
-
I am using this in a windows service. If the users dosen't shutdown the system for a longer period. I required my timer to schedule to a desired time.
In that case, use the timer, set at one minute, to kick off a procedure that will compare the current system time to the scheduled time of your task. If they match up, kick off your process, else do nothing. That way, if the machine gets restarted, you won't have to reset the timer to a calculated interval WAY off in the future. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
In that case, use the timer, set at one minute, to kick off a procedure that will compare the current system time to the scheduled time of your task. If they match up, kick off your process, else do nothing. That way, if the machine gets restarted, you won't have to reset the timer to a calculated interval WAY off in the future. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
This is what I thought as solution. But just curious to know about the problem. Thanks, Jo.