first press of a button, set up timer to do something in 60 minutes
second press, re-set timer to now + 60 minutes
In order to do this, I need to determine if a timer is set to go off in the future. It would seem that the .isRunning feature of a timer would be what I need, but it seems that .isRunning only returns true if the timer is actually executing the timer’s code block, not if it’s merely scheduled sometime in the future.
Sooooo… how do I determine if a timer is set in the future, so I can reset it? I’d rather not blindly call timer.reschedule, since if the timer isn’t set in the first place it’ll generate an error.
There is timer.hasTerminated or you can make sure that the timer gets set to null after it has gone off. As others have suggested, make sure to set the variable to null wherever you happen to cancel it.