- John Dillon and Steve Cash
Timer
ITimer
Timer Methods
Timer() | Constructor for the Timer class |
SetAlarm() | Sets the alarm to go off at an absolute time (given by Time object) |
SetAlarm() | Sets the alarm to go off at a relative interval (given by # of milliseconds) for a specified number of times |
SetAlarm() | Sets the alarm to go off at a relative interval (given by TimeInterval object) for a specified number of times |
IsActive() | Returns true if the alarm is currently set to go off in the future |
Remaining() | Returns number of alarm occurrences remaining |
AddTimerAlarmHandler() | Registers an event handler for an alarm event using a method reference |
AddTimerAlarmHandler() | Registers an event handler for an alarm event using an ITimer reference |
OnTimerAlarm() | Default event handler for the timer alarm event |
ITimer Methods
OnTimerAlarm() | Virtual method to handle TimerAlarmEvent processing |
Derived Classes
None
See Also
Class Hierarchy, Time, TimerAlarmEvent
public method Timer()
Parameters
None
Return Value
None
Description
Constructor for the Timer class.
Timer Class
public method SetAlarm(Time AbsoluteTime)
Parameters
AbsoluteTime
Time alarm will go off
Return Value
None
Description
Sets an alarm within the Timer object to go off at the specified time (given as a Time object). When the alarm goes off, a TimeAlarmEvent is issued for this Timer object and normal Aztec event handling takes place. The alarm will only go off once and then is turned off.
Timer Class
public method SetAlarm(int RelativeTime, int RepeatCount = 1)
Parameters
RelativeTime
Number of milliseconds to wait before alarm goes off
RepeatCount
Number of times alarm is to be repeated
Return Value
None
Description
Sets an alarm within the Timer object to go off at a specified interval from when the alarm is set. The RelativeTime is specified in miliseconds. If the repeat count is greater than one, the alarm goes off at the same interval for the specified number of times. If RepeatCount is zero, it will continue to issue an alarm forever using the same interval each time.
Timer Class
public method SetAlarm(TimeInterval RelativeTime, int RepeatCount = 1)
Parameters
RelativeTime
Number of seconds and milliseconds (based on TimeInterval contents) to wait before alarm goes off
RepeatCount
Number of times alarm is to be repeated
Return Value
None
Description
Sets an alarm within the Timer object to go off at a specified interval from when the alarm is set. The RelativeTime is specified by a TimeInterval object, which contains the number of seconds and millseconds. If the repeat count is greater than one, the alarm goes off at the same interval for the specified number of times. If RepeatCount is zero, it will continue to issue an alarm forever using the same interval each time.
Timer Class
public method<bool> IsActive()
Parameters
None
Return Value
True if alarm is currently set
Description
This method returnstrue if the Timer is currently active. If an alarm is currently set, it is said to be active.
Timer Class
public method<int> Remaining()
Parameters
None
Return Value
Returns the repeat count still remaining
Description
This method returns the number of alarm instances still remaining from the original repeat count. The original repeat count is decremented by one each time the alarm event is issued. If the repeat count was set to zero (infinite repeat), this will method also return zero.
Timer Class
public method AddTimerAlarmHandler(TimerAlarmHandler Handler, Base ExtraObject = null)
Parameters
Handler
Method reference to be executed when the event occurs
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers a method reference to be executed when the timer alarm goes off. An optional object can also be registered which will be sent to each event handler as it is executed.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an alarm that goes off in one thread can be handled by event handlers executing in one or more other threads.
The TimerAlarmHandler data type represents a method reference specific to a handler for TimerAlarmEvent. TimerAlarmHandler is defined as follows:
public type<method<TimerAlarmEvent,Base>> TimerAlarmHandler
Given this definition, the method handler must be defined with the following signature (name can be anything):
public method TimerAlarmMethod(TimerAlarmEvent event, Base Extra) { }.
Timer Class
public method AddTimerAlarmHandler(ITimer Interface, Base ExtraObject = null)
Parameters
Interface
Reference to an ITimer object
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers an ITimer interface object to be executed when a timer alarm goes off. An optional object can also be registered which will be sent to each event handler as it is executed.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an alarm that goes off in one thread can be handled by event handlers executing in one or more other threads.
When the alarm goes off and the TimerAlarmEvent is issued, the OnTimerAlarm() method within the ITimer object will be executed.
Timer Class
public method virtual OnTimerAlarm(TimerAlarmEvent AlarmEvent, Base ExtraObject)
Parameters
AlarmEvent
TimerAlarmEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This method is the default event handler for TimerAlarmEvent within the Timer. It is invoked internally as a result of the timer alarm going off. This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the Timer.AddTimerAlarmHandler() method register the event handlers which get invoked by this method.
If this method is overridden by a class derived from Timer, it must call this implementation of the method if it needs to execute handlers registered with the Timer.AddTimerAlarmHandler() methods.
Timer Class
public method virtual OnTimerAlarm(TimerAlarmEvent AlarmEvent, Base ExtraObject)
Parameters
AlarmEvent
TimerAlarmEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This virtual method is the event handler for TimerAlarmEvent within the ITimer interface class. The method which overrides it is invoked when the alarm goes off and the interface object is registered with the Timer.AddTimerAlarmHandler() method.
ITimer Class