Timer

Module: ecere
Namespace: ecere::gui
Type: Class
Base Class: Instance

Description

A Timer object useful for performing actions based on a particular time delay.

Properties and Members

  userDatavoid *The Object to link the Timer to.
  delaySecondsThe number of seconds until the delay has expired.
  startedboolWhen true, the Timer is already active and counting.
  _delaySeconds

Virtual Methods

  DelayExpired Code within this Virtual Method will be executed when the number of seconds specified in the delay member has elapsed.

Non-Virtual Methods

  StartStart the Timer so that it is actively counting.
  StopStop the Timer so that it is no longer counting.

Usage


A Timer object is defined in the declaration section of code, with it's functionality being declared at initialization time.

Example

class Form1 : Window
{
Timer timer
{
this; // the Timer object belongs to the Form1 class.
delay = 0.01; // the time to wait is 0.01 seconds.
bool DelayExpired() // Override the virtual function to tell the Timer what to do.
{
Update(null); // redraw the entire window.
return true; // tell the program that everything went ok.
}
}; // terminate the initialization of timer.
}

Remarks


This is an excellent, simple way to refresh the current window at particular intervals without requiring user input.

See Also


GetTime(), Time