Closing a C# Application (including hidden forms)

In this article, we will be discussing about the proper way for closing a C# application (including hidden forms).

 

C# Applications with Multiple 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.

How to Properly Close a C# Application

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:

Application.Exit();

 

Get Started with .NET Programming Fast and Easy – Enroll to the Course!

Check our online course titled “.NET Programming for Beginners – Windows Forms with C#(special limited-time discount included in link).

Learn how to implement Windows Forms projects in .NET using Visual Studio and C#, how to implement multithreading, how to create deployment packages and installers for your .NET Windows Forms apps using ClickOnce in Visual Studio, and more!

Many live demonstrations and downloadable resources included!

.NET Programming for Beginners - Windows Forms with C# - Online Course
(Lifetime Access, Certificate of Completion, downloadable resources and more!)

Enroll Now with Discount!

 

Featured Online Courses:

 

Read Also:

 

Did you find this article useful and interesting?

Interested in SQL Server Administration? Find hundreds of useful SQL Server administration and troubleshooting articles in 9 Times Microsoft Data Platform MVP, Artemakis’ Artemiou eBook: “Administering SQL Server (Second Edition)“.

Check our other related .NET articles.

Check out our latest software releases!

Subscribe to our newsletter and stay up to date!

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© SQLNetHub