I have an architecture that includes polling browsers via ajax every 3 seconds for updates, and I would like to change this to a long poll .
I would like to have a lengthy survey of clients 1, 2 .. {n}, wait for updates and something will happen on the server to signal waiting clients to return. My first thought was to use EventWaitHandle, and I can do it easily if I just want to support 1 client. I would simply , which , to block a client, perhaps with a timeout, maybe not. In any case, it will allow me to support only one client (since it only wakes up 1 waiting thread), and I want n clients.AutoResetEvent WaitHandleWaitOneAutoResetEvent
I'm sure I need to use it , but I'm not sure when to call it after I (when waking up threads). Do I just need some arbitrary amount between and ?ManualResetEvent WaitHandleResetSetThread.SleepSetReset
In psuedo code, the awakening logic will be
- get
ManualResetEventWaitHandle - call
Set - make sure that all pending clients are awake to prevent new requests.
- call
Resetnow that all pending clients have received their updates
With the 3rd line, with which I find it difficult to work. I'm currently throwing an idea on what LastTxIDsupports the client / server and potentially uses 2 wait descriptors. However, before I went crazy with this implementation, I wanted to get feedback here to see how they would implement the logic of awakening.
Edit: suppose I am having problems with finding out that the maximum concurrent users found out either by setting up IIS, or hosting using WCF or another solution. I want to focus only on the logic of awakening.