how to cancel a scheduled command?

637 views
Skip to first unread message

Hamlet D'Arcy

unread,
Jul 21, 2011, 8:01:21 AM7/21/11
to Google Web Toolkit
I scheduled a command using:
Scheduler.get().scheduleFixedPeriod(RepeatingCommand, int);

Is there any way to cancel the command once scheduled?

Jens

unread,
Jul 21, 2011, 8:13:35 AM7/21/11
to google-we...@googlegroups.com
Hm I don't think so. But you can use GWT's Timer class instead. It has a cancel() method as well as a scheduleRepeating(int delayInMillis) method.

-- J.

Hamlet D'Arcy

unread,
Jul 21, 2011, 8:21:20 AM7/21/11
to Google Web Toolkit
Here is the answer:

The execute() method of Scheduler.RepeatingCommand returns a boolean.
If true, then the command will be invoked again. If false, it will be
cancelled.

public interface RepeatingCommand {
/**
* Returns true if the RepeatingCommand should be invoked again.
*/
boolean execute();

Jens

unread,
Jul 21, 2011, 8:29:56 AM7/21/11
to google-we...@googlegroups.com
Ahhh you are right! I totally forgot that. I mostly use Timer because I haven't repeating tasks that can decide on its own if they should continue or not.

-- J.
Reply all
Reply to author
Forward
0 new messages