问题
My application has no forms. It runs by calling Application.Run();
回答1:
Call
System.Windows.Forms.Application.Exit();
回答2:
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.
回答3:
Just like the MSDN documentation for the Application.Run() suggests:
- Application.Exit()
- Application.ExitThread()
Note, that most Windows Forms developers will not need to use Application.Run(). Are you sure you need message pumping in your app?
来源:https://stackoverflow.com/questions/181018/how-to-close-a-formless-c-sharp-application