请看这个:
var form = new Form();
form.Shown += (_, __) =>
{
var timer = new System.Windows.Forms.Timer { Interval = 1000 };
timer.Tick += (x, xx) =>
{
timer.Stop();
GC.KeepAlive(timer);
timer.Dispose();
form.Close();
Application.DoEvents(); // no effect
// it will cause form keep show
MessageBox.Show("asdf");
// but if this, that's fine
// BeginInvoke(new Action(() => MessageBox.Show("asdf")));
};
timer.Start();
};
form.ShowDialog();
form.Close
之前MessageBox.Show
,但form
在关闭 msgBox 之前不会关闭,请帮忙。
- 结尾 -
全部在代码中,为什么需要更多的单词?全部在代码中,为什么需要更多的单词?全部在代码中,为什么需要更多的单词?