Is Visual Studio Asp.Net Development Server Really Multi-Threaded?
Asked Answered
F

1

2

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);

}
}
Frazer answered 28/10, 2011 at 16:11 Comment(2)
You shouldn't really halt the main execution thread. This would work fine on worker threads you start. Similarly there are better mechanisms using the application object if you want to talk across sessions.Danieladaniele
@SimonHalsey Main exec thread is not affected by this. It was indeed related to the Session lock.Frazer
S
3

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.

Sylvie answered 28/10, 2011 at 16:17 Comment(1)
Thanks! Is this true for IIS as well?Frazer

© 2022 - 2024 — McMap. All rights reserved.