如何正確退出C#應用程序? - How to properly exit a C# application?

問題:

I have a published application in C#.我在C#中有一個已發佈的應用程序。 The problem here is whenever I close the main form by clicking on the red exit button, it closes the form but it doesn't close the application.這裏的問題是,每當我通過單擊紅色退出按鈕關閉主窗體時,它都會關閉窗體,但不會關閉應用程序。 I found this out when I tried shutting down the computer, hopeful that the application I made was running smoothly then I was bombarded by a lot of child windows with which I have put MessageBox Alerts.當我嘗試關閉計算機時,我發現了這一點,希望我製作的應用程序運行平穩,然後被放置MessageBox Alerts的許多子窗口轟炸。

I tried Application.Exit but it still calls all the child windows and alerts and I don't know how to use Environment.Exit and which integer to put into it.我嘗試了Application.Exit但它仍然調用所有子窗口和警報,並且我不知道如何使用Environment.Exit以及要放入哪個整數。

By the way, whenever my forms call the formclosed or form closing event I close the application with a this.Hide() function;順便說一句,每當我的表單調用formclosedform closing close事件時,我都會使用this.Hide()函數關閉應用程序; Does that affect how my application is behaving now?這會影響我的應用程序現在的行爲嗎?


解決方案:

參考一: https://stackoom.com/question/sS9M
參考二: How to properly exit a C# application?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章