|
-
Nov 12th, 2009, 01:56 AM
#4
Re: End program during input validation
 Originally Posted by Philly0494
Why is it that in some situations, "End" doesn't work to close the program while "Application.Exit()" will, and strangle enough I've seen "Application.Exit()" fail but when replaced with "End" the program exits as desired?
I've even experienced cases where End and Application.Exit() fail.. yet Application.ExitThread() succeeds. (Obviously this would only work on the main thread)
I've seen this several times and I'm always puzzled..
Btw, I know Application.Exit() can be overruled by other forms, just look at the documentation of the first overload of Application.Exit(e as System...)
I've never used Environment.Exit(0).. will this always work?
First up, never, ever use End. End is like terminating your process from the Task Manager. There's never a reason to do that in code.
As for Application.Exit being cancelled by a form, let's keep in mind that this your code we're talking about here. It's your code that would be calling Application.Exit and it's your code that would be cancelling it. If that's not the behaviour you want then why code it in the first place?
Environment.Exit is what you'd call in a Console app, given that the Application class is a member of System.Windows.Forms and only exists in WinForms apps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|