Closing a C# Application (including hidden forms)

There are many times when we develop C# applications, where we make use of several forms. To this end, there are times that we are using the Hide() method for some of these forms thus hiding the forms, but not closing or disposing them.

Nevertheless, in the main form of a program we usually make use of an "Exit" button or another similar control. If the even code used behind this control calls the form to be closed or disposed, the application still runs due to the other hidden forms.

In order to totally close a C# application, including the hidden forms, you can use the following command in the event code of the "Exit" control:


Labels: ,