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!
mromeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Application.Exit();
0
mromeoAuthor Commented:

Do you know if this is the proper way to do this?  
0
topdog770Commented:
Generally speaking, yes.

Here's a pretty good summary

http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mromeoAuthor Commented:
Great post! Thanks.  
0
topdog770Commented:
You're welcome!  It's always nice to be able to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.