TROThreadTimer

Overview

The TROThreadTimer class allows to trigger an event repeatedly within a predefined time interval.
Unlike the VCL TTimer class, this class does not use the Windows message queue, but the Windows synchronization API (calls to TEvent.WaitFor). For platforms other than Windows, it uses short (10 ms) Sleep calls.
Be aware that the time interval counter for the next timer event starts after the previous time event handler returns, thus the actual time interval between sequential timer events may be longer than the specified interval.

Location

 

constructor Create (Boolean)    (declared in TROInitializedThread)

Creates a new class instance (standard thread class constructor).

constructor Create(CreateSuspended: Boolean)

Parameters:

  • CreateSuspended: When set to true, this parameter allows to create a thread that will not be started right after it is created. This allows to do some thread class configuration before the execution begins.

constructor Create (TROTimerEvent, integer)  overload

Initializes the instance with the given parameters.

constructor Create(aTimerEvent: TROTimerEvent; aTimeout: integer)

Parameters:

  • aTimerEvent: TimerEvent handler
  • aTimeout: Interval, in milliseconds, between firing TimerEvents

constructor Create (TROTimerEvent, integer, Boolean)  overload

Initializes the instance with the given parameters.

constructor Create(aTimerEvent: TROTimerEvent; aTimeout: integer; Synchronized: Boolean)

Parameters:

  • aTimerEvent: TimerEvent handler
  • aTimeout: Interval, in milliseconds, between firing TimerEvents
  • Synchronized: Indicates whether to use the TThread method to invoke the TimerEvent

AsyncFree

Allows to terminate a thread while it waits for the next awakening.

procedure AsyncFree

DoTerminate  protected override

procedure DoTerminate

Execute  protected override    (declared in TROInitializedThread)

This method will be executed on the background thread, and should contain the user code. In this class, the Execute method must not be overridden in descendant classes, override IntExecute instead.

procedure Execute

Free  reintroduce

procedure Free

Synchronized

If true, the TimerEvent is called through the TThread method.

property Synchronized: Boolean read write

TerminateWaitFor  virtual

Calls Terminate followed by WaitFor.

procedure TerminateWaitFor

Timeout

Interval, in milliseconds, between firing TimerEvents.

property Timeout: integer read write

WaitFor  reintroduce

Blocks the current thread until the current event receives a signal.

function WaitFor: Cardinal

 

Synchronized

If true, the TimerEvent is called through the TThread method.

property Synchronized: Boolean read write

Timeout

Interval, in milliseconds, between firing TimerEvents.

property Timeout: integer read write

 

constructor Create (Boolean)    (declared in TROInitializedThread)

Creates a new class instance (standard thread class constructor).

constructor Create(CreateSuspended: Boolean)

Parameters:

  • CreateSuspended: When set to true, this parameter allows to create a thread that will not be started right after it is created. This allows to do some thread class configuration before the execution begins.

constructor Create (TROTimerEvent, integer)  overload

Initializes the instance with the given parameters.

constructor Create(aTimerEvent: TROTimerEvent; aTimeout: integer)

Parameters:

  • aTimerEvent: TimerEvent handler
  • aTimeout: Interval, in milliseconds, between firing TimerEvents

constructor Create (TROTimerEvent, integer, Boolean)  overload

Initializes the instance with the given parameters.

constructor Create(aTimerEvent: TROTimerEvent; aTimeout: integer; Synchronized: Boolean)

Parameters:

  • aTimerEvent: TimerEvent handler
  • aTimeout: Interval, in milliseconds, between firing TimerEvents
  • Synchronized: Indicates whether to use the TThread method to invoke the TimerEvent

AsyncFree

Allows to terminate a thread while it waits for the next awakening.

procedure AsyncFree

DoTerminate  protected override

procedure DoTerminate

Execute  protected override    (declared in TROInitializedThread)

This method will be executed on the background thread, and should contain the user code. In this class, the Execute method must not be overridden in descendant classes, override IntExecute instead.

procedure Execute

Free  reintroduce

procedure Free

TerminateWaitFor  virtual

Calls Terminate followed by WaitFor.

procedure TerminateWaitFor

WaitFor  reintroduce

Blocks the current thread until the current event receives a signal.

function WaitFor: Cardinal