//主窗体
private void FormUpdate_Load(object sender, EventArgs e)
{
Thread thUpdate = new Thread(new ThreadStart(UpdateProgram));
thUpdate.Start();
}//更新线程调用的函数
private void UpdateProgram()
{
this.BeginInvoke(new EventHandler(UpdateFinish));
} //更新完成后在主界面上弹出一个messagebox提示
private void UpdateFinish(object sender, EventArgs e)
{
if (this.InvokeRequired)
{ //如果不是在主线程,调用委托返回到主线程
this.Invoke(new EventHandler(UpdateFinish));
return;
}
MessageBox.Show("更新完毕!");
}按理说我的
MessageBox.Show("更新完毕!");
是在thUpdate线程中通过一个托触发的,也就是说在主界面上弹出的MessageBox,那为什么MessageBox弹出后,主界面仍可激活,此时的MessageBox不是dialog模式嘛,还是我程序写错了,请高手指点,急!
private void FormUpdate_Load(object sender, EventArgs e)
{
Thread thUpdate = new Thread(new ThreadStart(UpdateProgram));
thUpdate.Start();
}//更新线程调用的函数
private void UpdateProgram()
{
this.BeginInvoke(new EventHandler(UpdateFinish));
} //更新完成后在主界面上弹出一个messagebox提示
private void UpdateFinish(object sender, EventArgs e)
{
if (this.InvokeRequired)
{ //如果不是在主线程,调用委托返回到主线程
this.Invoke(new EventHandler(UpdateFinish));
return;
}
MessageBox.Show("更新完毕!");
}按理说我的
MessageBox.Show("更新完毕!");
是在thUpdate线程中通过一个托触发的,也就是说在主界面上弹出的MessageBox,那为什么MessageBox弹出后,主界面仍可激活,此时的MessageBox不是dialog模式嘛,还是我程序写错了,请高手指点,急!
return"更新完毕@"!试试
和他不是一个线程的
自然就。