Too many timers?

Former Member
Former Member
Hello. I have a single timer defined as global variable. I start this timer (3 seconds, "false" parameter so it's a one-off) at the bottom of my onUpdate function within the View.

My call-back function stops the timer, then requests the View to update. When the select button is pressed, I stop the timer and request an update. I stop the timer in the onHide() function and also when the cancel button is pressed (to be sure).


This works, however, I got a CIQ error on one occasion. The log file said to "Too many timers".

Is there a better way to update a view every x seconds? Thanks in advance.

EDIT: I just added a timer.stop() at the beginning of the onUpdate function.
  • Ok, you're probably doing a widget or a watch-app. And what's happening is at some times, things aren't happening tin the order you expect.

    What I do, is this:

    I have one timer that gets started in initialize for the main view, and set it to repeat, at every second, minute, or whatever.....

    And in the simplest case, all onTimer does is a Ui.requestUpdate.

    And to handle things like a message you want to show for 5 seconds, I set "messDisplayMessageSecs=5" and maybe a boolean=true used in onUpdate.
    Then in onTimer, if messDisplayMessageSecs is >0, I dec it, and if it becomes 0, set the boolean=false; Then do a Ui.requestUpdate

    What I'm saying, is think about using a single timer that repeatedly fires, and have that single timer manage the stuff you want managed. There should be no need to ever stop that timer or create another.
  • Former Member
    Former Member
    Very cool. Thanks heaps for this, Jim!
  • Former Member
    Former Member
    There is a VM issue that has been corrected, but has not yet been released that will use up your timers if you call Timer.start() on a timer that is already running. You can avoid this issue by making sure you always stop your timer before restarting it. It sounds like you may already have this covered.
  • Former Member
    Former Member
    Thank you Brian. I think I'm all sorted now.