[英]putting Close(); in Form_FormClosing delays exit by 3-4 seconds
So in my program, sometimes a .net form will hide but not close, leaving it running in the background.所以在我的程序中,有时候一个.net的表单会隐藏但不会关闭,让它在后台运行。 Is there a way to make sure everything is closed?
有没有办法确保一切都已关闭?
Code:代码:
private void Main_FormClosing(object sender, FormClosedEventArgs e)
{
Close();
}
Thanks in advance!提前致谢!
The form is already closing, there is no need to call Close()
again from the FormClosing
event handler.表单已经关闭,无需从
FormClosing
事件处理程序再次调用Close()
。 Remove it.去掉它。
By placing Close
in the FormClosing
event handler you are probably causing infinite recursion and/or flooding of the message pump .通过将
Close
放置在FormClosing
事件处理程序中,您可能会导致消息泵的无限递归和/或泛滥。 The application is most likely crashing.该应用程序很可能会崩溃。
If your app isn't being responsive to closure, ensure you aren't running any foreground threads that could be preventing your app from exiting.如果您的应用程序没有响应关闭,请确保您没有运行任何可能阻止您的应用程序退出的前台线程。 See
Thread.IsBackground
for more information.有关详细信息,请参阅
Thread.IsBackground
。
So in my program, sometimes a .net form will hide but not close, leaving it running in the background.所以在我的程序中,有时 .net 表单会隐藏但不会关闭,使其在后台运行。 Is there a way to make sure everything is closed?
有没有办法确保一切都关闭?
Code:代码:
private void Main_FormClosing(object sender, FormClosedEventArgs e)
{
Close();
}
Thanks in advance!提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.