Timer problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Timer problem

I have linked a label to a timer. The label value increments by 1 after every timer event. If Timer interval is set to 1000 the increment takes place once in a second, but if interval is given a value of 1 then instead of 60,000 increments in a minute, i get a count of 1080 in a minute. Why is it so, could someone help me?

Comments

  • zibadianzibadian Posts: 6,349Member
    : I have linked a label to a timer. The label value increments by 1 after every timer event. If Timer interval is set to 1000 the increment takes place once in a second, but if interval is given a value of 1 then instead of 60,000 increments in a minute, i get a count of 1080 in a minute. Why is it so, could someone help me?
    :
    The timer does nothing than handle the wm_timer messages sent by windows. The precise minimum interval is variable and lot bigger than 1 ms, because windows cannot sent the timer message each ms (due to the nature of windows).
    If you have an event which must be done each ms, it is best to use a tight loop instead of a TTimer. Even then that event might not be called each second, because of background processes and thread-switching. This alternative will cause a heavy processor load, and might greatly slow down the computer or even lock the program.
  • rajsharajsha Posts: 75Member
    : : I have linked a label to a timer. The label value increments by 1 after every timer event. If Timer interval is set to 1000 the increment takes place once in a second, but if interval is given a value of 1 then instead of 60,000 increments in a minute, i get a count of 1080 in a minute. Why is it so, could someone help me?
    : :
    : The timer does nothing than handle the wm_timer messages sent by windows. The precise minimum interval is variable and lot bigger than 1 ms, because windows cannot sent the timer message each ms (due to the nature of windows).
    : If you have an event which must be done each ms, it is best to use a tight loop instead of a TTimer. Even then that event might not be called each second, because of background processes and thread-switching. This alternative will cause a heavy processor load, and might greatly slow down the computer or even lock the program.
    :
    Thanks for the insight :)


Sign In or Register to comment.