C# 表单不会在 FormClosing 事件上关闭
将以下代码添加到我的代码隐藏后,我的表单不会关闭。
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
MyThreadingObj.Dispose();
}
After I added the following code to my code-behind, my form doesn't get closed.
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
MyThreadingObj.Dispose();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来添加上述代码会阻止您的
Form
关闭。如果是这样,那么最可能的原因是MyTHreadingObj.Dispose()
语句引发异常。尝试将语句包装在 try/catch 中,看看是否是这种情况It sounds like adding the above code prevents your
Form
from closing. If so then the most likely cause is that theMyTHreadingObj.Dispose()
statement is throwing an exception. Try wrapping the statement in a try/catch and seeing if this is the case