The IlvTimer Class
Rogue Wave® Views has an internal mechanism for implementing
timers. The internal mechanism is hidden and system-dependent. It is based on the
IlvTimer class.
The purpose of a timer is to call a function repeatedly, once every given time period. If you want one of your functions to be called in this way, create an
IlvTimer instance and call its member function
run. The timer object calls its member function
doIt each time this period expires. Timers are based on the timeout mechanisms of the display system.
The timer automatically repeats the call to
doIt after every period if not specified to run only once. Before calling
doIt, the event loop disables the timer. After returning from
doIt, if it is not a run-once timer and if it is still disabled (it can be enabled by a call to
run from within the timer’s callback), the timer is enabled again. This mechanism shows that a timer is not active during its own callback, even if the callback contains a local event loop. This is only true when the timer is triggered by the event loop, not when the application explicitly calls the
doIt method. The application is responsible for deleting the timers it has created.
Note: If the function called by the timer takes too much time to execute compared to the periodicity of the timer, the periodicity may not be respected. |
The
IlvTimer class can be used in two different cases:
The first case supposes that you have a user-defined function which must match the
IlvTimerProc type:
typedef void (* IlvTimerProc)(IlvTimer* timer,IlAny userarg);
In this case, you simply instantiate an
IlvTimer object, specifying this function and an argument it can use.
The second case uses a derived subclass of
IlvTimer with overloading of the member function
doIt.
Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.