GWT Timer doesn't work

391 views
Skip to first unread message

Hanna Varakhobava

unread,
Jan 16, 2012, 10:14:58 AM1/16/12
to Google Web Toolkit
Hello everyone!

I have a long operation and a progress bar that should be updated
every second.
Long operation is an RPC, that retrieve a collection with some
information. I call another RPC to know the progress of my operation.
I have Timer subclass, where in void run() I get a progress. I do the
following:

...

retrieveCollection(); // RPC, retunrs immediatly
runTimer();

...

public void runTimer(){
new Timer {...}.scheduleRepeating(1000);
}

The problem is that void run() starts only after the long operation is
finished, though sheduleRepeating() executes almost immediatly (i.e.
there is a long delay between execution of scheduleRepeating() and
run()).

Can you help me somehow? I want to get information about operation
progress while it's executing.

Regards,
Hanna Varakhobava

Hanna Varakhobava

unread,
Jan 19, 2012, 3:24:30 AM1/19/12
to Google Web Toolkit
Hey, somebody...

Peter D.

unread,
Feb 24, 2012, 3:36:44 PM2/24/12
to Google Web Toolkit
Has a solution been found to this issue? I have encountered the same
thing, with no luck.

On Jan 19, 2:24 am, Hanna Varakhobava <h.varakhob...@gmail.com> wrote:
> Hey, somebody...

Patrick Tucker

unread,
Feb 26, 2012, 5:38:48 PM2/26/12
to Google Web Toolkit
You should execute the Timer right away, by directly calling its
run(). Then in the run() determine whether or not it needs to run
again. If so, use schedule(int) to make it run() again. The process
should be similar to how an IncrementalCommand would work...

Santosh kumar

unread,
Feb 27, 2012, 6:00:32 AM2/27/12
to google-we...@googlegroups.com
Try this,

           Timer timer = new Timer() {
                 public void run() {
                     // Do Rpc. i.e., retrieveCollection

                     @Override
                     public void onFailure(Throwable throwable) {
                         // if needed
                         timer.schedule(100);
                     }

                     @Override
                     public void onSuccess(Result result) {
                         // do logic
                         timer.schedule(100);
                     }
                 }
             };
             timer.schedule(100);


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Santosh Kumar K
Reply all
Reply to author
Forward
0 new messages