beginTimer(delay: Integer; option: Integer; eventTag: Integer);
The beginTimer method of the Object class arms a timer on the receiver and registers the receiver for timer notification.
When the specified timer delay (or period) expires, the system calls the timerEvent method for the object that registered the notification. If a negative value for is specified for the delay parameter, the minimum timer granularity of one (1msec is used.
A specific object can register multiple timers of different durations. The eventTag parameter can then be used by the timerEvent method to determine which timer has expired.
The parameters for the beginTimer method are listed in the following table.
Parameter | Description |
---|---|
delay | Integer value (in milliseconds) for the timer delay |
option |
|
eventTag | User-specified literal or constant that can be used to identify a specific timer event |
In JADE thin client mode, use of timers whose logic interacts with the presentation client side of the thin client processing may cause a processing loop if the interval between timer calls is less than the time taken to process each request. This could arise over a slower-speed line where the transmission time to the presentation client becomes significant.
When you develop an application that could run in JADE thin client mode, use timers with care. When a timer event occurs, it notifies the application server, which then echoes the event to all attached presentation clients; that is, the application server sends the notification to each presentation client, which then sends a response to the application server. This can have a considerable impact on network traffic.
Timers are deactivated when the process that armed them terminates. Similarly, notifications are unsubscribed when the process that subscribed to them terminates. As timer events are not transported between nodes, a timer armed in a server method will not invoke the timerEvent callback on the client node.
The following example shows the activation of a timer.
optionActivateTimer_click(menuItem: MenuItem input) updating; begin if self.timeInterval <> 0 then if optionActivateTimer.caption = "Deactivate Timer" then self.endTimer(0); optionActivateTimer.caption := "Activate Timer"; else beginTimer(self.timeInterval * 1000, Timer_Continuous, 0); optionActivateTimer.caption := "Deactivate Timer"; endif; endif; end;
The following code fragment checks if the timer is active, and if so, stops the timer and restarts it with a new value.
if optionActivateTimer.caption = "Deactivate Timer" then self.endTimer(0); optionActivateTimer.caption := "Activate Timer"; if self.timeInterval <> 0 then beginTimer(self.timeInterval * 1000, Timer_Continuous, 0); optionActivateTimer.caption := "Deactivate Timer"; endif; endif;
Use the getTimerStatus method to return the status of the timer specified in the eventTag parameter.