MainLoopTimerToken
ΒΆ
You can use the token to remove or replace the timer task.
-- You can store the timer task token in a global variable and use it to acknowledge that the timer task is already registered.
if updateDataToken == nil then
updateDataToken = MainLoopScheduler.prependTimer(
MainLoopStage.USER,
"UpdateDataObjects",
TimerRecurrence.Recurring,
millis(5),
function()
dataObjects.speed:setValue(currentSpeed)
end
)
end
-- You can use the previously stored token to remove the timer task. Note that compared to a simple task, the stage does not need to be passed.
if updateDataToken ~= nil then
MainLoopScheduler.removeTimer(updateDataToken)
updateDataToken = nil
end