在頁面點擊一個按鈕,其目的是在按鈕中做兩件事情,一件需要點擊按鈕馬上完成,另一件事情是點擊按鈕后做其他事情。如果按順序一次做完感覺特別耗時,下面簡單羅列一下。
protected void Button1_Click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; //在這做第一件事情 dowork(); //做完后馬上啟動線程 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.aspx','','');</script>");//通過注冊即可打開窗口Page.RegisterStartupScript("", "<script>window.open('login.aspx','','');</script>");}
新聞熱點
疑難解答
圖片精選