简体   繁体   中英

Why does my Application.Exit(); call fail?

I am coding in C#, and I have an exit button on my form that calls Application.Exit(); Now most of the time the button works without an issue at all, but occasionally the program doesn't seem to recognize that the program is being told to close, as if the button doesn't work any longer? There are no errors being thrown it just seems that the button doesn't register that its being clicked, even though visibly it shows the button being pressed. The most recent issue with the exit button came after the program sat for 20 minutes and then I told it to exit. Thanks for any thoughts on the matter.

Application.Exit() does not necessarily force an application to exit immediately. Here's a nice breakdown of Application.Exit() vs Enivronment.Exit():

http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx

And of course the MSDN official word:

http://msdn.microsoft.com/en-us/library/ms157894.aspx

Other than those thoughts, we'd need to see the code to give advise on what precisely is going on with your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM