是的Visual Studio Asp.Net开发服务器真的多线程? [英] Is Visual Studio Asp.Net Development Server Really Multi-Threaded?

查看:147
本文介绍了是的Visual Studio Asp.Net开发服务器真的多线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调试在VS2010一个WebProject,在本地开发服务器上运行(卡西尼?)。其中一个ASPX页面中调用ManualResetEvent.WaitOne(),另一页aspx页面调用ManualResetEvent.Set()(同一全局对象上)释放的第一页。

当我看着在VS2010的主题列表似乎有大量的工作线程。然而,Web服务器似乎封锁的ManualResetEvent.WaitOne()调用,同时停止处理任何事情。为此该ManualResetEvent.Set()不会加载,除非.WaitOne()超时。

这是怎么回事?

  //样品code类SyncTest { 私人System.Threading.ManualResetEvent eConnected =
       新System.Threading.ManualResetEvent(假);
 私人BOOL isConnected;公共SyncTest()
{
    this.isConnected = FALSE;
}公共无效SetConnected(布尔州)
{
    isConnected =状态;
    如果(州)
        eConnected.Set();
    其他
        eConnected.Reset();
}公共BOOL为waitForConnection(INT超时)
{
    返回eConnected.WaitOne(超时);}
}


解决方案

Web服务器仅在从每个用户一次处理一个页面。

如果你想从一个用户请求的并行运行的页面,你必须做出的网页(除一人外)无会话。

=的EnableSessionState假 @Page 指令的页面,使之无会话。

这当然意味着你不能确定使用的会话数据的请求。如果你想知道谁请求的页面,你必须沿着请求发送。

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

}
}

解决方案

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.

这篇关于是的Visual Studio Asp.Net开发服务器真的多线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆