Looks like my timer doesn't pauses properly...

Hi there,

I made some few timer functions:

timer.safeCancel = function(timerID) if timerID ~= nil then timer.cancel(timerID) end return nil end timer.safePause = function(timerID) if timerID then return timer.pause(timerID) end end timer.safeResume = function(timerID) if timerID then return timer.resume(timerID) end end timer.safePauseResume = function(timerID, isPause) if isPause then return timer.safePause(timerID) else return timer.safeResume(timerID) end end

It worked as expected, but now I’m pausing a timer through my “safePauseResume” and the timer ends up calling the callback

I’ve the build version 2014.2161, and this bug appeared some days ago. I was wondering if somebody else had the same problem…

timer.safePauseResume = function(timerID, isPause, isResume) if isPause then return timer.safePause(timerID) elseif isResume then return timer.safeResume(timerID) end end

Try that.

Hi abtekk,

Haven’t tried this piece of code since that’s how I call this function:

local function onPause(event) timer.safePauseResume(myTimerId, event.isPause) end Runtime:addEventListener("pause", onPause) ... Runtime:dispatchEvent({ name = "pause, ", isPause = true }) ... Runtime:dispatchEvent({ name = "pause, ", isPause = false })

Your code wouldn’t make any difference…

Did you check that you are passing the correct timer handles?

Yep, pretty sure

Ok, I already solved

All my functions were ok, the problem was I was performing a couple of timers but setting both timerId’s at the same variable – while I was pausing the last one, the first one kept going on

So you weren’t passing the correct timer handle :slight_smile:

timer.safePauseResume = function(timerID, isPause, isResume) if isPause then return timer.safePause(timerID) elseif isResume then return timer.safeResume(timerID) end end

Try that.

Hi abtekk,

Haven’t tried this piece of code since that’s how I call this function:

local function onPause(event) timer.safePauseResume(myTimerId, event.isPause) end Runtime:addEventListener("pause", onPause) ... Runtime:dispatchEvent({ name = "pause, ", isPause = true }) ... Runtime:dispatchEvent({ name = "pause, ", isPause = false })

Your code wouldn’t make any difference…

Did you check that you are passing the correct timer handles?

Yep, pretty sure

Ok, I already solved

All my functions were ok, the problem was I was performing a couple of timers but setting both timerId’s at the same variable – while I was pausing the last one, the first one kept going on

So you weren’t passing the correct timer handle :slight_smile: