A question regarding understanding timer vs. delay

I have a question about how timers with delays work - I don’t seem to fully understand the principle yet.

I’ve noticed that it obviously makes a difference whether I use, for example, a 33ms (once) timer without a delay or a 0ms timer with a 33ms delay.
In my case, the timer without a delay caused some unpredictable behavior in the script I’m working on, which seems to be very time-sensitive.
When I then set the timer to 0 and added a 33ms delay instead, everything ran reliably the way I wanted.
I’m now wondering what causes the difference?
In both cases, aren’t the events (actions) triggered by the timer delayed by 33 ms?
But what’s the difference between a 33 ms once-timer and a 0 ms once-timer delayed by 33 ms?
Understanding this would help me rely less on trial and error :slight_smile:
Thank you

Hi,
Thanks for your question.

The difference is that a 0 ms with a delay of 33ms will always fire after 33ms and you will not be able to stop it with a kill timer function.

With a tmer,33ms timer with no delay, it will trigger after 33ms unless you stop the timer in which case it will never trigger. If your incoming trigger continues more than once, then the delay will be extended to be 33ms after the last incoming trigger. If there are no more triggers and the timer was not stopped before 33ms then it will trigger, however if you stop the timer before 33ms then it will never trigger.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Hi Steve, thanks so much for your reply. I had to read it through a few times, but it’s explained really well.
I think I get it now.
The difference in my case was probably that the trigger was triggered multiple times by incoming events, which sometimes “delayed the delay” :slight_smile: , and that’s probably what caused the unpredictability.
Thanks!

1 Like