Question

Having gone through a few reads, including...

...I think I'm ready to give long polling a shot.

From the second link, my understanding is that the Async Pattern allows us to:

  1. receive a request on the WCF server
  2. call BeginMyMethod which returns an IAsyncResult
  3. hang onto the IAsyncResult somewhere while the thread that received the request "safely rests" - or is released? - without consuming any additional resources
  4. "whip the IAsyncResult back out" when a relevant business logic event occurs
  5. use the IAsyncResult to call EndMyMethod, during which we complete the response (i.e., write data back to the client)

Do my assumptions sound correct? I also assume this is vastly scalable due to the above mechanism keeping zero threads tied up waiting for events.

Is this the best way to implement WCF long polling today and with .NET 4.5?

Était-ce utile?

La solution

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.

Autres conseils

Have you considered publisher-subscriber pattern over a duplex channel?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top