Package com.ms.util Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class Timer

Constructors , Methods

public class Timer {
  // Constructors
  public Timer(long p)
  public Timer(long p, int id)
  public Timer(long p, boolean r)
  public Timer(long p, int id, boolean r)
  public Timer(TimerListener defaultListener, long p)
  public Timer(TimerListener defaultListener, long p, int id)
  public Timer(TimerListener defaultListener, long p, boolean r)
  public Timer(TimerListener defaultListener, long p, int id, boolean r)
  // Methods
  public long getPeriod()
  public boolean getRepeat()
  public int getUserID()
  public synchronized void addTimerListener(TimerListener listener)
  public synchronized void removeTimerListener(TimerListener listener)
  public synchronized boolean isRunning()
  public synchronized void start()
  public synchronized void stop()
}

Implements a timer event source.


Constructors


Timer

public Timer(long p)

Constructs a one-shot timer with the specified period.

ParameterDescription
p The initial period of the timer.


Timer

public Timer(long p, int id)

Constructs a one-shot timer with a specific period and user-defined identifier.

ParameterDescription
p The initial period of the timer.
id The user-defined identifier for the timer.


Timer

public Timer(long p, boolean r)

Constructs a one-shot or repeating timer with the specified periond.

ParameterDescription
p The initial period of the timer.
r Specifies whether the timer is repeating (vs. one-shot).


Timer

public Timer(long p, int id, boolean r)

Constructs a one-shot or repeating timer with the specified period.

ParameterDescription
p The initial period of the timer.
id The user-defined identifier for the timer.
r Specifies whether the timer is repeating (vs. one-shot).


Timer

public Timer(TimerListener defaultListener, long p)

Constructs a one-shot timer with the specified period and initial listener.

ParameterDescription
defaultListener An initial listener to add to the timer.
p The initial period of the timer.


Timer

public Timer(TimerListener defaultListener, long p, int id)

Constructs a one-shot timer with the specified period and initial listener.

ParameterDescription
defaultListener An initial listener to add to the timer.
p The initial period of the timer.
id The user-defined identifier for the timer.


Timer

public Timer(TimerListener defaultListener, long p, boolean r)

Constructs a one-shot or repeating timer with the specified period and initial listener.

ParameterDescription
defaultListener An initial listener to add to the timer.
p The initial period of the timer.
r Specifies whether the timer is repeating (vs. one-shot).


Timer

public Timer(TimerListener defaultListener, long p, int id, boolean r)

Constructs a one-shot or repeating timer with the specified period and initial listener.

ParameterDescription
defaultListener An initial listener to add to the timer.
p The initial period of the timer.
r Specifies whether the timer is repeating (vs. one-shot).


Methods


addTimerListener

public synchronized void addTimerListener(TimerListener listener)

Adds the specified listener to the timer.

ParameterDescription
listener The listener to add.


getPeriod

public long getPeriod()

Retrieves the period of the timer.

Return Value:

Returns the number of milliseconds that must elapse before the timer fires.


getRepeat

public boolean getRepeat()

Retrieves the repeat flag for the timer.

Return Value:

Returns true if the timer is a repeating timer, flase if one-shot.


getUserID

public int getUserID()

Retrieves the user-defined id associated with the timer.

Return Value:

Returns the integer identifier of the timer.


isRunning

public synchronized boolean isRunning()

Queries the run status of the timer.

Return Value:

Returns true if the timer is currently running, false otherwise.


removeTimerListener

public synchronized void removeTimerListener(TimerListener listener)

Removes the specified listener from the timer. This method prevents future timer events from being generated for the listener. Timer events which have already been generated may still be delivered.

ParameterDescription
listener The listener to remove.


start

public synchronized void start()

(re)Starts the timer. If the timer is already running, calls to this method are ignored.


stop

public synchronized void stop()

Stops the timer. This method prevents future timer events from being generated. Timer events which have already been generated may still be delivered to listeners. If the timer is not presently running, calls to this method are ignored.



Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.