请教关于多线程问题?
[color=#FF0000][/color]看了网上的例子,自己试了一下,发现下面的地方执行不进去,请高手帮忙看看!
private void LongTime(object str)
{
string s = string.Empty;
if (str != null)
{
s = str.ToString();
}
else
{
s = "tset";
}
for (int i = 0; i < 100000; i++) --这里设断点发现就是执行不进去
{
s += i.ToString();
}
Response.Write(s);
}
protected void Button1_Click(object sender, EventArgs e)
{
if (ThreadPool.QueueUserWorkItem(new WaitCallback(LongTime), TextBox1.Text))
{
Label1.Text = "Successfully";
System.Threading.Thread.Sleep(1000);
}
else
{
Label1.Text = "failed";
}
}
------解决方案--------------------
如果在asp.net中,你可以考虑使用异步页
http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
http://www.microsoft.com/china/msdn/library/webservices/asp.net/issuesWickedCodetoc.mspx?mfr=true