thanks for the hints.

My asynchronous callback actually looks like this:

private AsyncCallback<List<Replicable>> callback = new
AsyncCallback<List<Replicable>>() {
                public void onFailure(Throwable throwable) {
                                timer.schedule(UPDATE_PERIOD);
                }
                public void onSuccess(List<Replicable> replicables) {
        //....code
                        timer.schedule(UPDATE_PERIOD);
                }
        };

private Timer timer = new Timer() {
                @Override
                public void run() {
                        update();
                }
};

timer.schedule(UPDATE_PERIOD);

In this case, the results I am getting from server should always come
in proper order, since the next asynchronous request is only started
in onSuccess or onFailure blocks. Right?

For blinking I am using exactly this. My custom widgets (extending
from Composite) implement blink() and add/remove css as appropriate.
However, I am doing blinking in another timer, partly because interval
is shorter (500ms) and also because this is conceptually a different
task and placed in another class.

        private Timer timer = new Timer() {
                @Override
                public void run() {
                        blinkBlinkables();
                }
        };
timer.scheduleRepeating(500);

In this case I am using scheduleRepeating instead of schedule since
the code flow is not asynchronous, as I think.

I though that having 2 timers running along each other may be causing
the problems, should it? Maybe it is better to have just one that
would run two separate tasks (updates and blinking) or I am missing
something?
Thanks

On 24 Mrz., 04:42, Vitali Lovich <[email protected]> wrote:
> It's all Javascript so it's all going to be UTF AFAIK.  As for the updates,
> I think you're architecture is just wrong (you could potentially see results
> from the server out of order).
>
> A better approach would be
>
> myCallback = new AsyncCallback<T> {
>    void onFailure(Throwable t) { fetchDataFromServer(); }
>    void onSuccess(T r) { fetchDataFromServer(); }
>
> }
>
> fetchDataFromServer()
> {
>      rpcCall(myCallback);
>
> }
>
> That way, if you've got a slow client your not going to overwhelm them where
> you're generating timer events faster than they can be handled.  It should
> also scale up & down gracefully with the performance of the client
> browser/machine.
>
> If you want to ensure a minimum of 2 seconds, then do:
>
> fetchDataFromServer() {
>   fetchTimer.schedule(Math.max(1, System.currentTimeMillis() - lastUpdate));
>   lastUpdate = System.currentTimeMillis();
>
> }
>
> & then fetchTimer would actually do the rpc invocation.
>
> As for the blinking, I'm not sure how you are doing it, but I would
> recommend adding & removing a CSS class name (i.e addStyleName or.
> addStyleDependantName). & have the CSS actually define what the visual
> representation is.
>
> On Mon, Mar 23, 2009 at 10:15 PM, denis56 <[email protected]>wrote:
>
>
>
> > His,
>
> > does anyone know if there are performance implications with having 2
> > timers running on a single page?
>
> > I am designing an application where one timer does background fetching
> > of updates (2s) while the other (0.5s) updates gui elements to achieve
> > blinking behavior. It is especially noticeable in IE, that the
> > background updates take longer than 2s and that the browser is
> > jittering and fails to respond immediately. Has anyone encountered
> > something like that. Maybe having 2 timers is too much, have no idea.
>
> > Also, do GWT UI components understand ISO-8859-1 encoding? I cannot
> > display non-ASCII letters in a label, however, the data coming from a
> > RPC invocation displays properly. strange.
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to