asp.net如何在事件中启动线程来打开一个页面
在页面点击一个按钮,其目的是在按钮中做两件事情,一件需要点击按钮马上完成,另一件事情是点击按钮后做其他事情。如果按顺序一次做完感觉特别耗时,下面简单罗列一下。[csharp] view plaincopyprint?
protected void button1_click(object sender, eventargs e)
{
label1.text = textbox1.text;
//在这做第一件事情
protected void button1_click(object sender, eventargs e)
{
label1.text = textbox1.text;
//在这做第一件事情[csharp] view plaincopyprint?
dowork();
dowork();[csharp] view plaincopyprint?
//做完后马上启动线程
system.threading.thread thread = new system.threading.thread(new system.threading.threadstart(threadchild));
thread.start();
}
//做完后马上启动线程
system.threading.thread thread = new system.threading.thread(new system.threading.threadstart(threadchild));
thread.start();
}
线程中处理完后打开一个窗口
public void threadchild()
{
label2.text = datetime.now.tostring();
//response.write("");
//响应http必然报错
//response.write("<script>window.open('login.x','','');</script>");
//通过注册即可打开窗口
page.registerstartupscript("", "<script>window.open('login.aspx','','');</script>");
}