17
Views
2
Comments
Solved
Stop Timer - Kill Switch
Question

In another post you recommended a kill switch in a timer that is expected to run for more than a minute or two.  Could you elaborate on how to do this?

mvp_badge
MVP
Rank: #17
Solution

Hi,

You implement the "kill switch" by means of a site property of type Boolean.

In your timer logic at the beginning or in any for each loop you check it's value, if true you let the logic end.

So setting the site property to true while the timer runs will stop it.

If the timer is started while the site property is True it will immediately stop.

This is a form of defensive coding required because OutSystems does not provide an easy build in way to stop a running timer.

In the case you refer too you probably want to avoid s timer runs in a time out. So you check in the for each logic of your timer if you almost reach the time out value, and if you do, you start the timer using s wake timer action end end the current running timer.

This article from my fellow MVP Justin James is a must read on writing safe timers

https://link.medium.com/wic3A1SBydb

Regards,

Daniel


Rank: #26776

Thanks.