How is one supposed to exit an application such as when the user clicks on the Exit menu item from the File menu?
I have tried:
this.Dispose();
this.Exit();
Application.ShutDown();
Application.Exit();
Application.Dispose();
Among many others. Nothing works.
To exit your application you can call
As described in the documentation to the
Application.Shutdownmethod you can also modify the shutdown behavior of your application by specifying a ShutdownMode:Please also note that
Application.Current.Shutdown();may only be called from the thread that created theApplicationobject, i.e. normally the main thread.