首页 > > > winform 神奇的问题高手进
1.Form2 打开后马上就关闭了???为什么??
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Thread tr;
private void button1_Click(object sender, EventArgs e)
{
tr = new Thread(new ThreadStart(Do));
tr.IsBackground = true;
tr.Start();
}
private void Do()
{
Form2 f = new Form2();
f.Show();
}
}
2.MessageBox 不能到最前面来。。被Form2窗体挡住了...??为什么呀??
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Thread tr;
private void button1_Click(object sender, EventArgs e)
{
tr = new Thread(new ThreadStart(Do));
tr.IsBackground = true;
tr.Start();
Thread.Sleep(2000);
MessageBox.Show("晕!!!");
}
private void Do()
{
Form2 f = new Form2(); f.ShowDialog();
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758/viewspace-3166994/ ,如需转载,请注明出处,否则将追究法律责任。