为什么要等待异步Web服务调用 [英] Why Wait for Asynchronous Web Services Calls

查看:125
本文介绍了为什么要等待异步Web服务调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WebServices的经历MSDN文档。 这里和的此处,这两个环节谈调用Web服务并等待回应,这也是我所见过的同时异步执行大势所趋。

I was going through MSDN documentation on WebServices. Here and here, both these links talk about calling a webservice and wait for the response, which is also a general trend that I have seen while asynch implementation.

我不明白,为什么我们还需要等待服务调用返回?而且,如果大家都在等待,为什么不做一个同步调用。一个异步调用其次是等待和同步调用之间的区别是什么?

I don't understand "why do we need to wait for service call to return"? And, if we are waiting why don't make an synchronous call. What is the difference between an "asynch call followed by wait" and a "synchronous call"?

推荐答案

天生我才必有用,异步调用需要,而你去做点别的事情做的事情。有两种方法可以做到这一点:

To be useful, the asynchronous call needs to do its thing while you go do something else. There are two ways to do that:

  1. 异步处理提供一个回调方法,以当它完成,也可以通知您

定期检查异步手柄,如果查看其状态已更改为已完成。

您不会使用WaitHandle的做这两件事情。然而,WaitHandle的类可以使客户端进行异步调用,并等待:

You wouldn't use a WaitHandle to do these two things. However, the WaitHandle class makes it possible for clients to make an asynchronous call and wait for:

  • 在一个XML Web服务 ( WaitHandle.WaitOne ),
  • 第一的许多XML Web服务 ( WaitHandle.WaitAny ),或
  • 在所有的许多XML Web服务 ( WaitHandle.WaitAll的
  • a single XML Web service (WaitHandle.WaitOne),
  • the first of many XML Web services (WaitHandle.WaitAny), or
  • all of many XML Web services (WaitHandle.WaitAll)

返回结果。

在换句话说,如果你使用的WaitOne 了WaitAny 在返回几个结果异步Web服务,可以从您的Web服务调用获得一个结果,和的处理它,而你正在等待其余结果的。

In other words, if you use WaitOne or WaitAny on an asynchronous web service that returns several results, you can obtain a single result from your web service call, and process it while you are waiting on the remaining results.

这篇关于为什么要等待异步Web服务调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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