GWT使RPC阻塞 [英] GWT make RPC blocking

查看:112
本文介绍了GWT使RPC阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使gwt rpc阻塞?即应用程序阻塞,直到从服务器接收到响应为止

据我所知,没有gwt rpc阻止,因为它是与异步回调相反的想法。



但您可以使用这两种方法


  1. 定时器。计数定时器并检查是否有任何不为空的返回对象,并停止并取消定时器并继续工作。如果计时器处于活动状态,请不要做其他工作这是非常非常低效的方式。 缺少OO设计模式和if-else-if语句太多

  2. 调用Rpc并执行 onSuccess() code>方法。它保证你的方法已经完成,并成功完成,然后继续其他方法。

我的建议是第二个(onSuccess)。我想再次提到,阻止从来就不是一个好主意。


Is it possible to make a gwt rpc blocking? i.e. the application blocks until a response is received from the server

解决方案

As far as I know there is no gwt rpc blocking because it is opposite idea to the asynchronous callback.

But you can use these two methods

  1. Timer. Count timer and check that there is any return object that is not null and stop and cancel timer and continue your job. If timer is active don't do other job. This is very very inefficient way. Lack of OO design pattern and too many if-else-if statements
  2. Call Rpc and do all actions in onSuccess() method. It guarantees that your method is finished and successfully finished then continue to other methods.

My advise is 2nd one (onSuccess). I want to mention again that blocking is never a good idea

这篇关于GWT使RPC阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆