mromeo
asked on
What is the proper way to exit a CE .Net Compact Framework application?
I am trying to write a simple CE program in C#, using the .Net Compact Framework. The first thing this app does is open a login dialog box. This dialog box also has an "Exit" button on it. If the user hits the exit button, I simply want to exit. I wrote the code this way:
LogonDialog ld = new LogonDialog(cfgFN);
DialogResult dr = ld.ShowDialog();
if (dr == DialogResult.Cancel)
{
this.Close();
}
else
{
.................
}
When I execute the above code so and the user hits the Exit button, the app exits, but I get an ObjectDisposedException before it actually exits. If I chang:
this.Close();
to
System.Windows.Forms.Appli cation.Exi t();
return;
the app will return without this error. But this code just doesn't look right to me. What is the proper way to exit from a CE .Net application? Are either of the above correct?
Thanks!
LogonDialog ld = new LogonDialog(cfgFN);
DialogResult dr = ld.ShowDialog();
if (dr == DialogResult.Cancel)
{
this.Close();
}
else
{
.................
}
When I execute the above code so and the user hits the Exit button, the app exits, but I get an ObjectDisposedException before it actually exits. If I chang:
this.Close();
to
System.Windows.Forms.Appli
return;
the app will return without this error. But this code just doesn't look right to me. What is the proper way to exit from a CE .Net application? Are either of the above correct?
Thanks!
ASKER
Do you know if this is the proper way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great post! Thanks.
You're welcome! It's always nice to be able to help.
Application.Exit();