Need clarification on the Timer function

So let’s say I do this

function myFunction() print("YAY!") end timer.performWithDelay (5000, myFunction, 1)

Does myFunction run in the background at the time of the timer’s triggered and show the result after 5 seconds?

OR, does myFunction run after 5 second?

I am suspecting it’s the former because once the timer triggers, there seems to be nothing I can do to stop myFunction from running.

Is there a way to do this?
Btw, Which one is less resource heavy, using timer.performWithDelay, or grabbing time stamps using system.getTimer and enterFrame event to get time elapsed?
[import]uid: 39031 topic_id: 13295 reply_id: 313295[/import]

You should be able to cancel the timer with timer.cancel http://developer.anscamobile.com/reference/index/timercancel [import]uid: 56623 topic_id: 13295 reply_id: 48835[/import]

timer.cancel doesn’t seem to cancel what’s already in motion.
I am trying to cancel myFunction from executing AFTER timer.performWithDelay (5000, myFunction, 1) has been triggered but before myFunction actually executes, which is 5 seconds in this case. [import]uid: 39031 topic_id: 13295 reply_id: 48870[/import]

Anyone? [import]uid: 39031 topic_id: 13295 reply_id: 49064[/import]

So are you saying this does not work? (I have not tested)

timerID = timer.performWithDelay (5000, myFunction, 1) timer.cancel(timerID) [import]uid: 56623 topic_id: 13295 reply_id: 49174[/import]

it will work (I have not tested too) but no doubt it will work [import]uid: 12482 topic_id: 13295 reply_id: 49177[/import]

Hey, guys.
Thanks for the replies.
It seem to be working as intended now although I have no idea what was causing it to not work. Guess that’s the result of sleep deprivation.
Anyway, thanks for your help! [import]uid: 39031 topic_id: 13295 reply_id: 49245[/import]