Whoops,
obviously, in the code sample, the AsyncCallback object returned by
doLengthComputation() is not an AsyncCallback<String> ...
and I must have forgotten a closing bracket in the poll() function...
still, any ideas?
Thank You
On 23 Set, 14:38, Palietta <[EMAIL PROTECTED]> wrote:
> Here is a sample. It might contain errors but displays what I
> basically tried to do.
>
> // Obviously there is an asynchronous version of this interface
> public interface MyService extends RemoteService {
> public String requestStatusMessage();
>
> public void doLengthyComputation();
>
> }
>
> MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class);
> Timer t = new MyTimer();
>
> public void callMainService() {
> t.scheduleRepeating(1000);
> ServiceDefTarget endpoint = (ServiceDefTarget) service;
> endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "mymodule");
> AsyncCallback<String> callback = new AsyncCallback<String>() {
> // whatever the outcome, stop the polling timer
> public void onFailure(Throwable caught) {
> t.cancel();
> // do something to show failure
> }
>
> public void onSuccess(String result) {
> t.cancel();
> // do something else
> }
> // start the polling timer right before calling the main
> service
> t.run();
> service.doLengthyComputation();
>
> }
>
> public class MyTimer extends Timer {
> public void run() {
> poll();
> }
>
> public void poll() {
> ServiceDefTarget endpoint = (ServiceDefTarget) service;
> endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() +
> "mymodule");
> AsyncCallback<String> callback = new AsyncCallback<String>() {
> public void onFailure(Throwable caught) {
> System.out.println("polling failed");
> }
>
> public void onSuccess(String result) {
> System.out.println(result);
> }
> service.requestStatusMessage();
> }
>
> }
>
> On 23 Set, 13:17, Lothar Kimmeringer <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > Palietta schrieb:
>
> > > So I created a client-side Timer which, every second, polls another
> > > remote service that simply returns this state variable. This timer is
> > > started right before the main service is called, and is halted after
> > > the service returns.
>
> > > Being these calls asynchronous, this method didn't work. All scheduled
> > > Timer calls returned after the main service altogether.
>
> > > I know it might be a dumb question, but it would really be helpful for
> > > me to be able to provide the user with continued feedback on the state
> > > of the service they called.
>
> > Can you provide some source how you call the long running task
> > and create the timer? I have some ideas why this fails, but
> > it's only guessing without knowing more.
>
> > Independent from that you might google for "Comet GWT". This
> > might be a solution for you as well.
>
> > Regards, Lothar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---