WinForms Application.Exit 不一定退出应用程序 [英] WinForms Application.Exit does not exit the app necessarily

查看:30
本文介绍了WinForms Application.Exit 不一定退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MSDN 上,我读到调用 Application.Exit 不必每次都退出.我想知道是什么原因造成的?我的意思是什么时候我可以预期 Application.Exit 不会退出应用程序?

on the MSDN I have read that calling Application.Exit does not have to exit every time. I would like to know what could cause that? I mean when I could expect that Application.Exit will not exit the application?

推荐答案

Application.Exit 会为每个打开的表单调用 FormClosing,并且可以取消此事件.如果任何表单取消了此事件,Application.Exit 将停止而不做任何事情.否则所有表格将被关闭.但是,如果您有任何非后台线程在工作(除了主线程之外),您的应用程序将不会通过 Application.Exit 完成.

Application.Exit will call FormClosing for every opened form, and this event can be cancelled. If any form has cancelled this event, Application.Exit will stop without doing anything. Else all forms will be closed. But, if you have any non-background threads working (in additional to main thread) your application will not be finished by Application.Exit.

这篇关于WinForms Application.Exit 不一定退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆