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, string)    (declared in TROThread)

Initializes the instance with the given arguments.

constructor Create(aCreateSuspended: Boolean; const aName: string)

Parameters:

  • aCreateSuspended: If true, Execute won’t be called until after Resume is called; if false, Execute is called immediately.
  • aName: Become the value of the Name property.

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

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.

AsyncFree

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

procedure AsyncFree

DoTerminate  protected override    (declared in TROThread)

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    (declared in TROThread)

procedure Free

Name  protected    (declared in TROThread)

Sets a readable name for the thread.

property Name: string read

SetName  protected    (declared in TROThread)

procedure SetName(const aName: string)

Parameters:

  • aName:

Synchronized

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

property Synchronized: Boolean read write

TerminateWaitFor  virtual    (declared in TROThread)

Utility method that combines a call to Terminate with a subsequent call to WaitFor.

procedure TerminateWaitFor

Timeout

Interval, in milliseconds, between firing TimerEvents.

property Timeout: Integer read write

WaitFor  reintroduce    (declared in TROThread)

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

function WaitFor: Cardinal

 

Name  protected    (declared in TROThread)

Sets a readable name for the thread.

property Name: string read

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, string)    (declared in TROThread)

Initializes the instance with the given arguments.

constructor Create(aCreateSuspended: Boolean; const aName: string)

Parameters:

  • aCreateSuspended: If true, Execute won’t be called until after Resume is called; if false, Execute is called immediately.
  • aName: Become the value of the Name property.

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

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.

AsyncFree

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

procedure AsyncFree

DoTerminate  protected override    (declared in TROThread)

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    (declared in TROThread)

procedure Free

SetName  protected    (declared in TROThread)

procedure SetName(const aName: string)

Parameters:

  • aName:

TerminateWaitFor  virtual    (declared in TROThread)

Utility method that combines a call to Terminate with a subsequent call to WaitFor.

procedure TerminateWaitFor

WaitFor  reintroduce    (declared in TROThread)

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

function WaitFor: Cardinal