Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process does not close after closing the form

Tags:

c#

winforms

I have a first form that calls another one and then disappears (frm.visible = false). This form should not come back after being called once, but it's the main form (the first one that appears when you launch the program). I am trying to make it so when you close the second form, both forms close, I have tried multiple things but all of them leave the process active.

This is the code that I use :

private void frmCreation_FormClosing(object sender, FormClosingEventArgs e)
        {
            frmProperties frm = new frmProperties();
            frm.Dispose();
        }
        //I have also tried frm.Close() which also does not work

This code close the two forms, but the process remains active. How do I counter this?

like image 986
MrRoy Avatar asked Apr 26 '11 23:04

MrRoy


2 Answers

Application.Exit() tells your App to close itself. Environment.Exit(0) tells Windows to kill it.

I prefer the latter since it really closes your app no matter what.

like image 176
logicPwn Avatar answered Nov 18 '22 19:11

logicPwn


Maybe you are looking for Application.Exit()?

like image 39
DarkSquirrel42 Avatar answered Nov 18 '22 20:11

DarkSquirrel42