C# 中缓慢的 WebService 调用超时

发布于 2024-09-19 09:24:44 字数 114 浏览 1 评论 0原文

我正在调用具有可变响应时间的网络服务。如果响应时间超过 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 技术交流群。

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

发布评论

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

评论(1

旧话新听 2024-09-26 09:24:44

假设您使用的是生成的客户端代理,源自 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.

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