捕获应用程序退出事件

编程入门 行业动态 更新时间:2024-10-08 20:34:30
本文介绍了捕获应用程序退出事件 - 的WinForms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是可能的应用程序停止点击时捕获Windows窗体关闭事件。 我知道,应用程序将停止工作,但没有任何可用的方法,谁在任何情况下火的时候,应用程序被关闭? 我发现从谷歌这些方法,但他们没有工作:

Is this possible to capture Windows form close event when clicked on application stop. I know application stop working but is there any method available who will fire in any case when application is closing? I found these methods from google but they are not working:

AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

是否有可能去接近事件当点击应用程序停止按钮?

Is it possible to get close event when click on application stop button?

推荐答案

在Program.cs的文件,你必须有这些方法的之前 Application.Run:

In Program.cs file, you must have those methods before Application.Run :

[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); Application.Run(new MainForm()); }

您还可以使用处置事件在MainForm的(在申请使用的表格.RUN法)。

You can also use the Disposed event on the MainForm (the form used in Application.Run method).

更多推荐

捕获应用程序退出事件

本文发布于:2023-11-03 05:04:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554305.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   事件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!