Is there a way to stop a recurring timer that was started in a extended BehaviorDelegate class Initialize function when the class terminates? Reason I'm asking is because I got some ERA "Too Many Timers" crashes. I start three timers, but one in a Glance view and another in a Main view. Since they start in the onShow and stop in the onHide, they shouldn't be active at the same time right?
function onShow() { _refreshTimer = new Timer.Timer(); if (Properties.getValue("titleScrolling")) { _refreshTimer.start(method(:refreshView), 50, true); } else { _refreshTimer.start(method(:refreshView), 500, true); } } function onHide() { _refreshTimer.stop(); _refreshTimer = null; }
So that leaves the one started in the BehaviorDelegate
class MainDelegate extends Ui.BehaviorDelegate { : var _workTimer; : function initialize(view as MainView, data, handler) { BehaviorDelegate.initialize(); : _workTimer = new Timer.Timer(); : _workTimer.start(method(:workerTimer), 100, true); : } : }
(the ':' means there are irrelevant code in between the relevant lines)
The watch that had the (many) too many timers errors is a Fenix 5X Plus, so Glance isn't an issue. That MainDelegate class is only created in getInitialView.
I don't understand why it would create too many timers