线程中打开 Form 窗体
private void button1_Click(object sender, EventArgs e)
{
Thread showThread = new Thread(new ThreadStart(ShowForm));
showThread.Start();
}
delegate void ShowCallback();
//private Form2 modForm = new Form2();
private void ShowForm()
{
if (this.InvokeRequired)
{
ShowCallback d = new ShowCallback(ShowForm);
this.Invoke(d, new object[] { });
}
else
{
//if (modForm.IsDisposed)
//{
// modForm = new Form2();
//}
Form2 modForm = new Form2();
modForm.Show();
}
}
{
Thread showThread = new Thread(new ThreadStart(ShowForm));
showThread.Start();
}
delegate void ShowCallback();
//private Form2 modForm = new Form2();
private void ShowForm()
{
if (this.InvokeRequired)
{
ShowCallback d = new ShowCallback(ShowForm);
this.Invoke(d, new object[] { });
}
else
{
//if (modForm.IsDisposed)
//{
// modForm = new Form2();
//}
Form2 modForm = new Form2();
modForm.Show();
}
}