在使用Winform開發的過程,不可避免的要使用多線程,其中會在多線程中會調用窗口的ShowDialog方法,但實際上並非模式窗口。html
private void Form1_Load(object sender, EventArgs e) { Thread thread = new Thread(remind); thread.IsBackground = true; thread.Start(); } private void remind() { while (true) { string h = "0"; string m = "23"; if (h == DateTime.Now.Hour.ToString() && m == DateTime.Now.Minute.ToString() && DateTime.Now.Second.ToString() == "0") { Form2 form2 = new Form2(); form2.ShowDialog(); Thread.Sleep(1000); } } }
form2的ShowDialog()顯示並非模式窗體,如何解決這種狀況???多線程
Form2 form2 = new Form2(); form2.ShowDialog(this);
這個方法你能夠試試看。this