Link to home
Start Free TrialLog in
Avatar of mromeo
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.Application.Exit();
             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!
Avatar of topdog770
topdog770
Flag of United States of America image

That's the approach my several CE applications have taken.

Application.Exit();
Avatar of mromeo
mromeo

ASKER


Do you know if this is the proper way to do this?  
ASKER CERTIFIED SOLUTION
Avatar of topdog770
topdog770
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mromeo

ASKER

Great post! Thanks.  
You're welcome!  It's always nice to be able to help.