如何防止 .NET 服务在等待依赖服务时超时

发布于 2024-07-12 01:41:51 字数 152 浏览 5 评论 0原文

我有一个基于 C# 的服务,该服务依赖于 MSMQ 服务。 在某些场景下,MSMQ服务需要很长时间才能启动,显然会导致C#服务超时。 我怎样才能以编程方式解决这个问题?

编辑:看来我正在处理的错误报告不正确,该服务最终确实启动了。 对于造成的混乱,我深表歉意

I have a C# based service that is dependent on the MSMQ service. In some scenarios the MSMQ service takes a long time to start, apparently resulting in a timeout of the C# service. How can I fix this programatically?

Edit: It appears that the bug report I was working on was incorrect, the service does indeed start eventually. I apologize for the confusion

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

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

发布评论

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

评论(1

笑饮青盏花 2024-07-19 01:41:51

通常,应该在单独的线程中等待队列,该线程应该直接在服务的 OnStart 方法中启动。
如果您这样做,启动命令就会成功,并且服务不会超时。

Normally waiting on a queue should be made in a separate thread, which should be started directly in the OnStart Method of the Service.
If you do it this way, the Start-command succeeds and the service will not time out.

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