MainLoopTaskToken
ΒΆ
You can use the token to remove or replace the task.
-- You can store the task token in a global variable and use it to acknowledge that the task is already registered.
if updateDataToken == nil then
updateDataToken = MainLoopScheduler.prependTask(
MainLoopStage.USER,
"UpdateDataObjects",
TaskRecurrence.Recurring,
function()
dataObjects.speed:setValue(currentSpeed)
end
)
end
-- You can use the previously stored token to remove the task.
if updateDataToken ~= nil then
MainLoopScheduler.removeTask(
MainLoopStage.USER,
updateDataToken
)
updateDataToken = nil
end