这是可能的应用程序停止点击时捕获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).
更多推荐
捕获应用程序退出事件
发布评论