winform 多線程中ShowDialog()步驟無效的解決辦法

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()顯示並非模式窗體,如何解決這種狀況???

解決辦法:this

 Form2 form2 = new Form2();

 form2.ShowDialog(this);
相關文章
相關標籤/搜索