同步使用 WCF 回调(双工)服务

发布于 2024-09-30 18:39:02 字数 189 浏览 3 评论 0原文

我有一个现有的 WCF 服务,现在需要使用外部 WCF 回调(也称为双工)服务。双工服务本质上是异步的,但我需要保持原始 WCF 服务同步。有一个众所周知的模式可以做到这一点吗?我需要注意的最重要的陷阱是什么?

我当前的意图是调用双工服务,然后等待引发 ManualResetEvent。当双工调用回调时,它将重置事件并使等待操作恢复并完成其工作。

I have an existing WCF service that I now need to have consume an external WCF callback (aka duplex) service. The duplex service is by its nature asynchronous and yet I need to keep my original WCF service synchronous. Is there a well known pattern to do this? What are the most important pitfalls I need to watch out for?

My current intention is to invoke the duplex service and then wait for a ManualResetEvent to be raised. When the callback is called by the duplex, it would reset the event and make the waiting operation resume and complete its work.

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

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

发布评论

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

评论(1

半世晨晓 2024-10-07 18:39:02

是的,我也会走这条路。请注意如何控制这些事件的生命周期。似乎您需要将一些 id 传递给双工服务,以便当回调到达时,该 id 可以解析为原始的 ManualResetEvent

Yes, I'd go this way too. Pay attention to how you control these events' lifetime. Seems like you'll need to pass some id to the duplex service so that, when callback arrives, this id could be resolved into the original ManualResetEvent.

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