Timer (PRIM_TIMR)

Executes code at intervals

Ancestors - Object (PRIM_OBJT)

Details

The Timer control is used to execute code at intervals.
 
The Interval property defines the millisecond gap between each Tick.
 
The single threaded nature of the LANSA runtime means that a timer tick is queued. Any activity already in progress will complete before the timer ticks.

Example

This example demonstrates basic timer functionality.
Begin_Com Role(*EXTENDS #PRIM_WEB) Height(457) Width(1169)
 
   Define_Com Class(#PRIM_VS.Style) Name(#Style1) Backgroundbrush(#Brush1) Foregroundbrush(#Brush2)
   Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush2) Color(Theme50)
   Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(Theme500)
 
   Define_Com Class(#prim_timr) Name(#Timer) Startup(Manual)
 
   Define_Com Class(#PRIM_PHBN) Name(#StartStop) Caption('Start') Displayposition(1) Left(24) Parent(#COM_OWNER) Tabposition(1) Top(32) Width(169)
   Define_Com Class(#PRIM_SPDT) Name(#Interval) Displayposition(2) Left(96) Parent(#COM_OWNER) Showselection(False) Showselectionhilight(False) Tabposition(2) Top(96) Width(96)
   Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Interval') Displayposition(3) Ellipses(Word) Height(25) Left(24) Parent(#COM_OWNER) Tabposition(3) Tabstop(False) Top(96) Verticalalignment(Center) Width(57)
   Define_Com Class(#PRIM_LABL) Name(#Ticking) Displayposition(4) Ellipses(Word) Height(90) Left(208) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(31) Verticalalignment(Center) Width(242) Alignment(Center) Style(#Style1) Caption('Ticking') Visible(False)
 
   Evtroutine Handling(#Com_owner.CreateInstance)
 
      #Interval := #Timer.Interval
 
   Endroutine
 
   Evtroutine Handling(#Interval.Changed)
 
      #Interval := #Interval.Value.Max( 1 #Interval.Value )
      #Timer.Interval := #Interval
 
   Endroutine
 
   Evtroutine Handling(#StartStop.Click)
 
      If (#Timer.IsStarted)
 
         #Timer.Stop
         #StartStop.Caption := "Start"
         #Ticking.visible := False
 
      Else
 
         #Timer.Start
         #StartStop.Caption := "Stop"
 
      Endif
 
   Endroutine
 
   Evtroutine Handling(#Timer.Tick)
 
      #Ticking.visible := *Not #Ticking.Visible
 
   Endroutine
 
End_Com

Properties

NameDescription
ComponentClassNameComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)
ComponentMembersComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)
ComponentPatternNameComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)
ComponentTagGeneric space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)
ComponentTypeComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)
ComponentTypeNameComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)
IntervalNumber of milliseconds between each tick
IsStartedReturns true if the timer is currently running
NameName identifies the component Inherited from Object (PRIM_OBJT)
OwnerOwner owns this component Inherited from Object (PRIM_OBJT)
ParentThe component instance to which this instance is attached. The visual container for a control or the collector of a set of child instances Inherited from Object (PRIM_OBJT)
StartupDefines whether the timer is started automatically or manually

Events

NameDescription
CreateInstanceCreateInstance is signalled when an instance of a component is created Inherited from Timer (PRIM_TIMR)
DestroyInstanceDestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Timer (PRIM_TIMR)
TickFired whenever the specified interval has elapsed

Methods

NameDescription
StartStart method starts the timer
StopStop method stops the timer

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2