为什么处理取消关闭会使我的 .NET 应用程序崩溃?

发布于 2024-09-06 09:31:14 字数 170 浏览 2 评论 0原文

我使用了这个线程的答案: 捕获控制台退出 C#

每当我关闭控制台时,我都会收到“---已停止工作” ”。从 Windows 7 开始。 有什么想法吗?

I used the answer from this thread:
Capture console exit C#

Whenever I close the console, I get a "--- has stopped working." from Windows 7.
Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时常饿 2024-09-13 09:31:14

1)恕我直言,这个答案的方法不一定是个好主意 - 如果您知道需要清理的事情,则进程出口尚未为您清理(例如,它已经进行了连接,文件句柄,内存、线程等),然后挂钩到应用程序域卸载或进程退出或类似类型的事件是一个更好的主意恕我直言

2)你是如何实现处理程序的?根据该问题中的评论,如果您让它返回 true,那就解释了您所看到的内容。

1) IMHO, that answer's approach isn't necessarily a good idea - if you know of things you need to clean up that process exit doesn't already clean up for you (for instance, it'll already do connections, file handles, memory, threads, etc), then hooking to the appdomain unload or process exit or similar kind of event is a better idea IMHO

2) how did you implement Handler? as per the comments in that question, if you had it return true, that explains what you're seeing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文