close program

  • Thread starter Thread starter kltr
  • Start date Start date
K

kltr

Hi,
My program developed with c# (Net compact framework) doesn't close
correctly.

I close my program as the following:
Application.Exit();

The program in 'Settings/System/Memory/programs' is not visible, and this is
good for me.
But, when I try to run my program another once, It doesn't start!

I found another method to open and close program:

public static Form1 myForm;

static void Main(){
myForm = new Form1();
myForm.ShowDialog();
}

and close:

private void menuExit_Click(object sender, System.EventArgs e) {
myForm .Close(); //I tried even with Dispose.
Application.Exit();
}

but is the same.

Thanks
karl
 
To call Application.Exit is not right way to close your application.
Start your main form through Application.Run:

static void Main()
{
Application.Run(new Form1());
}

And to close it correctly just call Close in you main form:

private void menuExit_Click(object sender, System.EventArgs e)
{
this.Close();
}

Also make sure that all your running threads are correctly stopped.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Back
Top