首页 新闻 赞助 找找看

多线程操作session问题

0
悬赏园豆:10 [待解决问题] 解决于 2011-06-20 19:16

PageA页面处理一个长时间的请求,并把请求时时更改的数据放到了session["a"]中,代码如下:

protected void Page_Load(object sender, EventArgs e)
{

if (Session["a"] == null)
{
Session[
"a"] = 1;
}
DateTime beginTime
= DateTime.Now;
int a = 1;
long b = 30000000;
while (a < b)
{
lock (Session["a"])
{
a
++;
Session[
"a"] = a;
}
}
DateTime endTime
= DateTime.Now;
TimeSpan span
= endTime - beginTime;
Label1.Text
= "耗时:" + span.TotalSeconds + "";

}

PageB页及时的反馈出session["a"]的值给用户 代码如下:

protected void Page_Load(object sender, EventArgs e)
{

DateTime beginTime
= DateTime.Now;
if (Session["times"] == null)
{
Session[
"times"] = 1;
}
int times = (int)Session["times"];
times
++;
Session[
"times"] = times;
Label2.Text
= times.ToString();
Label1.Text
= Session["a"] == null ? "null" : Session["a"].ToString();
DateTime endTime
= DateTime.Now;
TimeSpan span
= endTime - beginTime;
Label3.Text
= span.TotalSeconds + "";
}

现在出现的问题如下:

当用户请求PageA页面因为处理很长时间,用户在去请求PageA页面,但是IIS一直不会处理PageB页面的请求,直到PageA页面处理完毕,IIS才处理B页面,求解释,求解决方法。

lichaoxyz的主页 lichaoxyz | 初学一级 | 园豆:195
提问于:2011-05-21 19:16
< >
分享
所有回答(1)
0

你确定你这是多线程?

massinger | 园豆:706 (小虾三级) | 2011-05-24 13:46

我确定这不是多线程

支持(0) 反对(0) LiGoper | 园豆:32 (初学一级) | 2014-10-30 17:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册