On Tue, 25 Mar 2008 14:09:52 -0700, Dom <do********@gmail.comwrote:
How do I end a program while in Form_Load? I tried both this.Close(),
and Application.Exit(), but neither will just end the program there
and then. Instead, both allow Form_Load to continue.
Well, I suppose you could just throw an exception, or just put a "return"
statement after your call to Application.Exit(). That would prevent the
rest of your Load event handler from executing.
The Application.Exit() method isn't like the old CRT "exit()" function.
It doesn't terminate the process. It just signals to the application
message pumps to stop and closes all the windows.
I'm not aware of a .NET equivalent to "exit()", though of course an
unhandled exception can terminate the application, albeit messily. You
should avoid implementing code that just terminates the process. It's
extremely unlikely that there's a good reason for wanting to do this, and
you're better off exiting your application cleanly.
Pete