FutureBasic Logo

<<    Index    >> FutureBasic

timerbegin   statement / function



Syntax
[t =] timerbegin [fireDate [, timeinterval [, repeats ]]]
// code
timerend

Requires
macOS 10.12+

Description
timerbegin submits a block (i.e. the code between timerbegin and its closing timerend statement) for asynchronous execution on a timer queue and returns immediately. Blocks can be nested and each block must be terminated with the timerend statement.

Parameters
Parameter
Description
fireDate Optional. The time at which the timer should first fire. This can be a CFDateRef or a double value (seconds from now). Default = NULL.
timeInterval Optional. For a repeating timer, this parameter contains the number of seconds between firings of the timer. Default = 0.0.
repeats Optional. If YES, the timer will reschedule itself until invalidated. If NO, the timer will be invalidated after it fires. Default = NO.
 
Return value
A new TimerRef object, configured according to the specified parameters. The return value is optional.  

Examples
(1)
timerbegin // the timer runs immediately and invalidates after it fires
// do something
timerend

(2)
timerbegin , 1.0, YES // the timer runs after 1 second and fires every second
// do something
timerend

(3)
timerbegin 3.0 // run timer in 3 seconds from now
// do something
timerend

(4)
TimerRef t = timerbegin fn DateWithTimeIntervalSinceNow(4.0), 2.0, YES // run timer in 4 seconds from now, then every 2 seconds
// do something
timerend
// do something with the returned timer ref 't'

See also
FB's Timer.incl header
 
Apple documentation
NSTimer