Timer¶
[lide.widgets] ^1.0lide.widgets.timer 1.0
The Timer class allows you to execute code at specified intervals.
Its precision is platform-dependent, but in general will not be better than 1ms nor worse than 1s.
Start the timer with Timer:start() after constructing it before it actually starts sending notifications. It can be stopped later with Timer:stop()
Note: A timer can only be used from the main thread
Constructor¶
Timer class has a single constructor:
Timer:new ( number nTimerID, function fTimerHandler )
Arguments¶
These arguments are received by class constructor.
| Argument | Description |
|---|---|
| nTimerID | The Timer identificator |
| fTimerHandler | The Timer name |
Class Methods¶
These methods are defined by this class.
Timer:start¶
Start or restarts the timer. If milliseconds parameter is
-1(value by default), the previous value is used. Returns false if the timer could not be started, true otherwise (in MS Windows timers are a limited resource).If oneShot is false (the default), the Notify function will be called repeatedly until the timer is stopped. If
true, it will be called only once and the timer will stop automatically. To make your code more readable you may also use the following symbolic constants:
TIMER_CONTINUOUS = falseStart a normal, continuously running, timer TIMER_ONE_SHOT = trueStart a one shot timer If the timer was already running, it will be stopped by this method before restarting it.
| number | Timer:start( number nMilliseconds, bool bOneshot ) |
Timer:getInterval¶
Returns the current interval for the timer (in milliseconds).
| number | Timer:getInterval() |
Timer:isOneShot¶
Returnstrueif the timer is one shot, i.e. if it will stop after firing the first notification automatically.
| bool | Timer:isOneShot() |