asp.net is an implementation of starting threads in an event to open a page
- 2021-01-22 05:04:10
- OfStack
Click a button on the page, its purpose is to do two things in the button, one need to click the button to complete immediately, the other thing is to click the button to do other things. If it feels too time-consuming to do it one time in order, the following list is simple.
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
// In this first 1 thing
dowork();
// Start the thread as soon as you're done
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadChild));
thread.Start();
}
Open a window after processing in the thread
public void ThreadChild()
{
Label2.Text = DateTime.Now.ToString();
//Response.Write("");
// The response http Must be an error
//Response.Write("<script>window.open('login.aspx','','');</script>");
// Open the window by registering
Page.RegisterStartupScript("", "<script>window.open('login.aspx','','');</script>");
}