AddTimer()

Syntax

AddTimer(Timer, Timeout)
Description
Creates a new timer. BindEvent() can be used with #PB_Event_Timer to get the event. RemoveTimer() function can be used to remove the timer.

Parameters

Timer An user-defined number that identifies this timer. This value will later be returned from EventTimer() when a #PB_Event_Timer is received. It can also be used to remove the timer again with the RemoveTimer() function.
Timeout Specifies the amount of time (in milliseconds) between each #PB_Event_Timer events. The timer events will only be generated when there are no other events to be processed (timers are low-priority events). This means that the time that elapses between two timer events may be larger than the specified Timeout value. Timers are therefore not suited for precise timing but are rather intended to perform periodic tasks such as updating a gadget content or similar.

Return value

None.

Example

  Procedure TimerEvents()
    Debug "Timer event: " + EventTimer()
  EndProcedure
  
  AddTimer(0, 1000) ; First timer every seconds
  AddTimer(1, 3000) ; Second timer every 3 seconds
      
  BindEvent(#PB_Event_Timer, @TimerEvents())

See Also

RemoveTimer(), EventTimer()

Supported OS

All

System Index - BatteryLevel() ->