timer.cancel()

Type Function
Library timer.*
Revision 2017.3179
Keywords timer, delay, cancel
See also timer.performWithDelay()

Overview

Cancels a timer operation initiated with timer.performWithDelay().

Syntax

timer.cancel( timerID )
timerID (required)

Object. Handle returned by the call to timer.performWithDelay().

Example

local t = {}
function t:timer( event )
    local count = event.count
    print( "Table listener called " .. count .. " time(s)" )
    if count >= 3 then
        timer.cancel( event.source ) -- after 3rd invocation, cancel timer
    end
end
 
-- Register to call t's timer method an infinite number of times
timer.performWithDelay( 1000, t, 0 )