wnform 打开模式窗体的问题
主窗体的代码(BackTransparentScreen 对象是一个半透明的窗体,作用是在弹出NotifyScreen模式窗体时实现主窗体半透明的效果):
public bool ShowNotify(string title, string msg, bool isNeedReturn)
{
BackTransparentScreen backScreen = new BackTransparentScreen();
this.AddOwnedForm(backScreen);
backScreen.Show();
try
{
Mode.NotifyScreen notifyUC = new Mode.NotifyScreen(title, msg, isNeedReturn);
DialogResult result = notifyUC.ShowDialog();
return result == System.Windows.Forms.DialogResult.OK;
}
finally
{
this.RemoveOwnedForm(backScreen);
backScreen.Close();
}
}
NotifyScreen窗体有一个按钮用来关闭该窗体并设置窗体结果:
void btnOk_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
出现的问题:当运行完notifyUC.ShowDialog()时,窗体会关闭,然后半透明的窗体也会关闭,就在这时会出现主窗体闪烁一下,请帮忙看下原因. 尝试在finally{}里增加线程睡眠会出现模式窗体和主窗体卡在一起.