I am making a simple windows form application in Visual Studio. But I have a problem when I want to close the app. When I right-click it from taskbar and close it, I can see background process still running in Task Manager.
How do I kill whole app?
I have paced this in first form that is opening when app starts:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if(!exit)
{
if (MessageBox.Show("Close the app?", "Simple App", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
exit = true;
Close();
}
else
{
e.Cancel = true;
exit = false;
}
}
}
I added Application.Exit();
on all forms in OnFormClosing
event. And it is working good.