Pregunta

I'm debugging a WebProject in VS2010 that runs in the local dev server (cassini?). One of the aspx pages calls a ManualResetEvent.WaitOne() and another Page aspx page calls the ManualResetEvent.Set() (on the same Global object) to release the first page.

When I look at the thread list in VS2010 there seems to be lots of worker threads. However, the web server seems to halt processing anything while blocked by the ManualResetEvent.WaitOne() call. Therefor the ManualResetEvent.Set() does not load unless the .WaitOne() Times out.

What's going on here?

// Sample Code

Class SyncTest {

 private System.Threading.ManualResetEvent eConnected = 
       new System.Threading.ManualResetEvent(false);
 private bool isConnected;

public SyncTest ()
{
    this.isConnected = false;
}

public void SetConnected(bool state)
{
    isConnected = state;
    if (state)
        eConnected.Set();
    else
        eConnected.Reset();
}

public bool WaitForConnection(int timeout)
{
    return eConnected.WaitOne(timeout);

}
}
¿Fue útil?

Solución

The web server only processes one page at a time from each user.

If you want pages requested from one user to run in parallel, you have to make the pages (except one) sessionless.

Put EnableSessionState="false" in the @Page directive for a page to make it sessionless.

This of course means that you can't identify the request using the Session data. If you want to know who requested the page, you have to send it along in the request.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top