SimpleTimer is a timer class. It has the same timer resolution as TTimer, but it is more lightweight because it's derived from TObject in stead of TComponent. Furthermore, the same handle is shared between multiple instances of SimpleTimer. This makes it ideal for developers who need a timer in their own components or applications, but want to keep the resource usage minimal.
Enabled | property Enabled: Boolean; Enables (starts) or disables (stops) the timer. |
Default False |
Interval | property Interval: Cardinal; The interval of the timer in millisecs. NOTE: Specifying a value of 0 will cause the timer to stop, but will not set the Enabled property to false. |
Default 1000 |
AutoDisable | property AutoDisable: Boolean; If true, the timer will disable itself (Enabled is set to False) immediately after the next time it fires. Useful when you want a one-shot timer. |
Default False |
Create | constructor Create; Creates a new TSimpleTimer object. |
CreateEx | constructor CreateEx(AInterval: Cardinal; AOnTimer: TNotifyEvent); Creates a new TSimpleTimer object with the specified Interval property and OnTimer event. |
Destroy | destructor Destroy; override; Destroys the TSimpleTimer object. |
OnTimer | property OnTimer: TNotifyEvent; Called when the timer fires. |
GetSimpleTimerCount | function GetSimpleTimerCount: Cardinal; Returns the number of TSimpleTimer objects currently allocated. |
GetSimpleTimerActiveCount | function GetSimpleTimerActiveCount: Cardinal; Returns the number of TSimpleTimer objects that are currently active (enabled). |
procedure TForm1.FormCreate(Sender: TObject); begin SimpleTimer1 := TSimpleTimer.CreateEx(500, TimerProc1); SimpleTimer1.Enabled := True; end;This is what TimerProc1 might look like:
procedure TForm1.TimerProc1(Sender: TObject); begin ListBox1.Items.Add('SimpleTimer1 fired'); end;Remember to destroy the SimpleTimer object when your app. terminates.
Get the latest version from http://subsimple.com/delphi.asp.
Troels Jakobsen
troels.jakobsen@gmail.com