Hi,

I have built a widget for my GWT application that shows the latest
actions users of the application have performed. To refresh this
widget automatically I use a Timer and its schedule() method like
this:

    private final Timer t = new Timer() {
        @Override
        public void run() {
            // perform RPC call here to refresh the list of activities
            schedule(10000);
        }
    };
    ...
    t.schedule(10000);

I'm using schedule() here since scheduleRepeating() could lead to
shorter intervalls which I don't want to. However, I could also have
used scheduleRepeating() here, that's not the actual problem.

My problem/question is rather: When this widget is removed from the
DOM I'll have to cancel() the timer, so I override onUnload() and call
t.cancel() in there. Is this the method you would recommend or is
there some other fancy way of cancelling timers automatically when
widgets are unloaded/detached?

Thanks
Max

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to