Friday, February 11, 2011

How to close a formless C# application

My application has no forms. It runs by calling Application.Run();

  • Call System.Windows.Forms.Application.Exit();

    Esteban Araya : Did you use puppet accounts to upvote this question?
    Esteban Araya : Er.. answer, I meant answer.
  • The other option is Environment.Exit(), however if your application does rely on the Application classes, System.Windows.Forms.Application.Exit() is the more "proper" way of handling it.

  • Just like the MSDN documentation for the Application.Run() suggests:

    Note, that most Windows Forms developers will not need to use Application.Run(). Are you sure you need message pumping in your app?

0 comments:

Post a Comment