超时在C#中的异步Web服务调用 [英] timeout for asynchronous web service call in C#

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

问题描述

我使用C#和创建从客户端的一个ASP.Net ASMX Web服务代理服务器,通过使用添加Web引用... 2008 VSTS的功能。

I am using C# and created a proxy from a ASP.Net asmx Web Service at client side, by using Add Web Reference... feature of VSTS 2008.

而我使用的异步方法调用模型(即调用AsyncXXX方法,它会立即返回),并处理完整的事件(我添加事件处理程序来处理完整甚至当效应初探从服务器端接收的)。

And I am using the asynchronous method call model (i.e. call the AsyncXXX method, which will return immediately) and handles the complete event (I add event handler to handle the complete even when the reponse is received from server side).

我觉得如果服务器没有响应很长一段时间,整个事件不会被解雇。

I find if there is no response from server for a long time, the complete event will not be fired.

我的问题是,


  1. 它是预期的功能或我的错误,如果从服务器后调用AsyncXXX方法没有任何反应,完成事件处理程序将?不能叫

  1. Is it expected feature or my bug that if no response from server after call AsyncXXX method, complete event handler will not be called?

还有什么办法来分配超时值 - 这样我就不能在无限的完整事件处理程序等待

Are there any way to assign timeout value -- so that I do not wait on the complete event handler infinitely?

在此先感谢,
乔治

thanks in advance, George

推荐答案

在web.config中为你的web服务,您可以设置超时(你也需要改变不会在调试模式下,如果它是)。那么这应当引起它抛出一个异常,这将提高你完成的事件。然后你需要检查是否有异常,看它是否通过或失败

In the web.config for your webservice you can set a timeout (You will also need to change to not be in debug mode if it is). This should then cause it to throw an exception that will raise your completed event. You will then need to inspect for an exception to see if it passed or failed.

<system.web>
    <httpRuntime executionTimeout="120" />
</system.web>

这篇关于超时在C#中的异步Web服务调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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