Package com.smartgwt.client.event
Class SmartGwtTimer
java.lang.Object
com.smartgwt.client.event.SmartGwtTimer
SmartGwtTimer
is an alternative to GWT's built-in
Timer
class that may allow code to be
executed more efficiently. The SmartClient Framework is aware of threads run using a
SmartGwtTimer
, so extra work (e.g. reflowing
Layout
members, refreshing
DrawItem
s, etc.) queued by a timer's
run()
method gets processed before it returns control to its caller, instead of
being scheduled to run in a future (second) timer call.
Note that if you are replacing or updating components in a
Timer
and notice a visible flash, switching to a
SmartGwtTimer
, which offers identical public APIs to Timer
, may
solve the issue.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels this timer.boolean
Returns true if the timer is running.abstract void
run()
This method will be called when a timer fires.void
schedule
(int delayMillis) Schedules a timer to elapse in the future.void
scheduleRepeating
(int periodMillis) Schedules a timer that elapses repeatedly.
-
Constructor Details
-
SmartGwtTimer
public SmartGwtTimer()
-
-
Method Details
-
cancel
public void cancel()Cancels this timer. If the timer is not running, this is a no-op. -
isRunning
public boolean isRunning()Returns true if the timer is running. Timer is running if and only if it is scheduled but it is not expired or cancelled.- Returns:
- whether timer is running
-
schedule
public void schedule(int delayMillis) Schedules a timer to elapse in the future. If the timer is already running then it will be first canceled before re-scheduling.- Parameters:
delayMillis
- delay in milliseconds before timer fires
-
scheduleRepeating
public void scheduleRepeating(int periodMillis) Schedules a timer that elapses repeatedly. If the timer is already running then it will be first canceled before re-scheduling.- Parameters:
periodMillis
- delay in milliseconds between timer fires
-
run
public abstract void run()This method will be called when a timer fires. Override it to implement the timer's logic.
-