2

经过几次阅读,包括...

...我想我已经准备好进行长轮询了。

从第二个链接,我的理解是异步模式允许我们:

  1. 在 WCF 服务器上接收请求
  2. 调用返回 IAsyncResult 的 BeginMyMethod
  3. 当接收到请求的线程“安全地休息”或被释放时,挂在某处的 IAsyncResult 上?- 不消耗任何额外资源
  4. 发生相关业务逻辑事件时“将 IAsyncResult 退出”
  5. 使用 IAsyncResult 调用 EndMyMethod,在此期间我们完成响应(即,将数据写回客户端)

我的假设听起来正确吗?我还假设这是由于上述机制保持零线程等待事件而具有极大的可扩展性。

这是目前使用 .NET 4.5 实现 WCF 长轮询的最佳方式吗?

4

2 回答 2

1

I believe my initial impressions were wrong. When a WCF request handler thread receives a request and hands it off to a worker thread, I'd thought all resources were somehow being magically freed. This isn't the case as the worker thread becomes the one now doing the waiting! Which, as request volume gets large, doesn't sound much more scalable than traditional polling.

While frameworks like SignalR offer long polling, I don't think there's any way to construct it natively in WCF in a manner that doesn't tie up threads.

Some additional useful links I came across. Shockingly they appear to recommend traditional polling from a scalability point of view.

Let me know if you guys have any other insight.

于 2013-04-21T19:17:24.760 回答
0

您是否考虑过双工通道上的发布者-订阅者模式?

于 2013-07-22T17:11:01.947 回答