GWT 使 RPC 阻塞

发布于 2024-10-10 13:19:15 字数 42 浏览 11 评论 0原文

是否可以使 gwt rpc 阻塞?即应用程序阻塞,直到收到服务器的响应

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱格式化 2024-10-17 13:19:15

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

但是你可以使用Timer这两个方法

  1. 。计算计时器并检查是否有任何返回对象不为空,然后停止并取消计时器并继续您的工作。如果计时器处于活动状态,则不要执行其他工作。这是非常非常低效的方式。 缺乏OO设计模式和过多的if-else-if语句
  2. 调用Rpc并在onSuccess()方法中执行所有操作。它保证您的方法已完成并成功完成,然后继续其他方法。

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

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

够运 2024-10-17 13:19:15

嗯,同步 rpc 调用被 GWT 设计者称为邪恶。他们确实有非常有力的论据...但是你可以通过 hacks 成功同步 rpc..这是其中之一,
http://code.google.com/p/google -web-toolkit/issues/detail?id=4898

Well, synchronus rpc calls are called as evils by GWT designers. They do have very strong arguments... But you can succeed synchronous rpc by means of hacks..Here is one of them,
http://code.google.com/p/google-web-toolkit/issues/detail?id=4898

昔梦 2024-10-17 13:19:15

我想到的最简单的解决方案是从异步调用开始的地方“阻止”您的应用程序,直到填充完成,这将在 onSuccess() 方法的末尾。

我所说的阻止只是为了在中间显示一些 动画加载 gif页面。

The most simple solution that came to my mind would be to "block" your application from the point where the Asynchronous call starts till the filling is completed, which would be at the end of the onSuccess() method.

By blocking I mean just to show some animated loading gif in the middle of the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文