nsITimer

IID:29ee628e-a3ea-471f-965d-dc9f11d1c183
Inherits From:nsISupports

This interface is implemented by the following components:


Constants

Type of a timer that fires once only.
PRInt16 TYPE_ONE_SHOT = 0
After firing, a TYPE_REPEATING_SLACK timer is stopped and not restarted until its callback completes. Specified timer period will be at least the time between when processing for last firing the callback completes and when the next firing occurs.

This is the preferable repeating type for most situations.

PRInt16 TYPE_REPEATING_SLACK = 1
An TYPE_REPEATING_PRECISE repeating timer aims to have constant period between firings. The processing time for each timer callback should not influence the timer period. However, if the processing for the last timer firing could not be completed until just before the next firing occurs, then you could have two timer notification routines being executed in quick succession.
PRInt16 TYPE_REPEATING_PRECISE = 2

Properties

[noscript] readonly voidPtr* closure

The opaque pointer pass to initWithCallback.

PRUint32 delay

The millisecond delay of the timeout

PRUint32 type

The timer type : one shot or repeating


Methods

void cancel ( ) void init ( nsIObserver observer , PRUint32 delay , PRUint32 type ) void initWithCallback ( nsITimerCallback callback , PRUint32 delay , PRUint32 type ) [noscript] void initWithFuncCallback ( nsTimerCallbackFunc callback , voidPtr* closure , PRUint32 delay , PRUint32 type )

void cancel ( )

Cancel the timer. This method works on all types, not just on repeating timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse it by re-initializing it (to avoid object destruction and creation costs by conserving one timer instance).


void init ( nsIObserver observer , PRUint32 delay , PRUint32 type )

Initialize a timer that will fire after the said delay. A user must keep a reference to this timer till it is is no longer needed or has been cancelled.

Observe(nsISupports subject, => nsITimer string topic, => ``timer-callback'' wstring data => null

Arguments:
observer: the callback object that observes the ``timer-callback'' topic with the subject being the timer itself when the timer fires:
delay: delay in milliseconds for timer to fire
type: timer type per TYPE* consts defined above

void initWithCallback ( nsITimerCallback callback , PRUint32 delay , PRUint32 type )

Initialize a timer to fire after the given millisecond interval. This version takes a function to call and a closure to pass to that function.

Arguments:
callback
delay: The millisecond interval
type: Timer type per TYPE* consts defined above

void initWithFuncCallback ( nsTimerCallbackFunc callback , voidPtr* closure , PRUint32 delay , PRUint32 type )

Initialize a timer to fire after the given millisecond interval. This version takes a function to call and a closure to pass to that function.

Arguments:
callback
closure: An opaque pointer to pass to that function
delay: The millisecond interval
type: Timer type per TYPE* consts defined above

References

This interface is passed as an argument to the following methods:

nsITimerCallback.notify

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com