Search code examples
c#.netwinformsformclosing

Program still running in Task Manager


I've almost finished my first C# project apart from this last little 'bug'; when I run my C# Winforms application and close it, the process doesn't end in task manager, it becomes a background task.

Here is how I navigate between forms:

Settings form = new Settings();

form.Tag = this;
form.Show(this);

Hide();

Anyone know how to fix this?

Edit: Upon looking about, I found each Form has an event property to be ran when the form closes.


Solution

  • accoring to the documentation

    Environment.Exit Method Terminates the process and returns an exit code to the operating system

    Enviroment.Exit(0)