同步使用 WCF 回调(双工)服务
我有一个现有的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我也会走这条路。请注意如何控制这些事件的生命周期。似乎您需要将一些 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
.