The preferred method is using this.Close(). I will be adding a FAQ item on
this but for now, here is some info on using Application.Exit:
Application.Exit is a hard exit like Win32's PostQuitMessage(). It's meant
to pop off all message pumps, unwind the callstack and return execution to
the system.
The correct way to shut down an app on Windows (Win32 or .NET) is to close
its main application window (i.e. Form.Close). Any window that's still
present after the main message pump ends needs to be manually closed. It's
good practice to clean up your windows by closing them before your app exits
by calling Form.Close or Form.Dispose, depending on the intended behavior
People need to remember that .NET's OnClosing() is the managed version of
Win32's WM_CLOSE and not WM_DESTROY.
Additionally, if you use form.Close(), your app will get a chance to clean
up stuff, close files, etc.. by handling a OnClosing or OnClosed event.
These events don't get called if you rip your app out w/ Application.Exit.
--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.