Visual Studio Asp.Net 开发服务器真的是多线程的吗?
我正在 VS2010 中调试一个在本地开发服务器(cassini?)中运行的 WebProject。其中一个 aspx 页面调用 ManualResetEvent.WaitOne(),另一个 Page aspx 页面调用 ManualResetEvent.Set()(在同一个 Global 对象上)来释放第一页。
当我查看 VS2010 中的线程列表时,似乎有很多工作线程。然而,Web 服务器似乎在被 ManualResetEvent.WaitOne() 调用阻止时停止处理任何内容。因此,除非 .WaitOne() 超时,否则 ManualResetEvent.Set() 不会加载。
这是怎么回事?
// 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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web 服务器一次仅处理每个用户的一页。
如果您希望一个用户请求的页面并行运行,则必须使页面(除一个之外)无会话。
将
EnableSessionState="false"
放入页面的@Page
指令中,使其成为无会话状态。这当然意味着您无法使用会话数据来识别请求。如果您想知道谁请求了该页面,则必须将其连同请求一起发送。
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.