C# 中缓慢的 WebService 调用超时
我正在调用具有可变响应时间的网络服务。如果响应时间超过 15 秒,我希望能够“超时”请求。意思是,我将继续编写我的代码,而不是等待响应。一切都是用 C# 完成的。有人可以帮我提供一些关于如何执行此操作的代码示例吗?
im calling a webservice with variable response times. I want to be able to "Timeout" the request if a response takes longer than 15 seconds. Meaning, i will move forward in my code, not waiting for the response. Everything is done in C#. Could anyone help me out with some code examples on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是生成的客户端代理,源自 SoapHttpClientProtocol,调用 Web 服务(您是否在项目中添加了“Web 引用”?),那么应该有一个 Timeout 属性。
Assuming you are using a generated client side proxy, derived from SoapHttpClientProtocol, to invoke the web service (did you add a "Web Reference" to your project?) then there should be a Timeout property on the generated class.