Timer driving me nuts

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a timer on my form. The problem is no matter how large an interval I
set, the timer_tick event always gets called very fast. What am I doing
wrong?

Thanks

Regards
 
Hey John,
R u setting the timer interval at runtime after starting the timer?
If that is the case, set the timer interval before starting the timer.

Hope it helps.
 
I have set it at design time and it currently stands at 600000. Still too
fast almost like 1 second. I am running my process in the Timer_Tick event.

Thanks

Regards
 
Hello John,

If I remember correctly the Timer.Interval will accept a large numer, like
600000, however the only valid numbers are 0 through ~32000. Interval is
defined in milliseconds.

-Boo
 
Got it now thanks. My only problem now is to set the interval to about 5
minutes. If the highest interval the timer can take is 32000 (32 seconds?)
then how does one get round it?

Thanks again everyone.

Regards
 
from the help:
The interval can be between 1 and 64,767, inclusive, which means that
even the longest interval will not be much longer than one minute (about
64.8 seconds).

now if you need a larger timer try the following.

Add a static variable.

rease the variable each time you enter the sub. When you have the seconds
you need (if - end if) do your stuff

Jan
 
I've never heard of a 32/64/whatever sec limitation (except on Windows 3.x).
Both of the following works fine on my machine:

Timer1.Interval = 60000 '1 minute interval
Timer1.Start()

Timer1.Interval = 300000 '5 minute interval
Timer1.Start()


According to the docs for SetTimer (that System.Windows.Forms.Timer uses)
the maximum value for the interval is USER_TIMER_MAXIMUM. That constant is
defined in winuser.h as 0x7FFFFFFF

There must be something else that's wrong in this case. Show your code

/claes
 
I think there is a misunderstanding between the readers.
There are 2 types of timers available:
1. The timer control (System.Windows.Forms.Timer)
2. The timer class (System.Timers.Timer)

The first one is a control, and has a limititation of 64,767 seconds.
The second one is a class, and does not have this limitation.
 
John said:
Got it now thanks. My only problem now is to set the interval to about 5
minutes. If the highest interval the timer can take is 32000 (32 seconds?)
then how does one get round it?

Thanks again everyone.

Regards

How about storing the time when you start then let the timer check every
second orso to check the timespan between the current time and the
stored start time.
 
The first is a class too...

As I posted below I successfully used System.Windows.Forms.Timer with a 5
minute (i.e. 300 seconds) timeout. Can you show me where this limitation of
the System.Windows.Forms.Timer control is documented (beacuse I can't find
it)?

/claes
 
I found it in MSDN:
http://msdn2.microsoft.com/en-us/library/xy0zeach.aspx

It actually says that the timer interval is limited to max 64 seconds. Looks
incorrect to me though. Setting it to 2 minutes correctly fires the Tick
event every 2 minutes as expected in my text application. And the underlying
API (SetTimer) doesn't have any 64 sec limitation so why would the Timer
class have it?

/claes
 
Back
Top