How to close a formless C# application

我怕爱的太早我们不能终老 提交于 2019-12-13 04:26:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!