How to detect when application terminates?

前端 未结 5 794
我寻月下人不归
我寻月下人不归 2020-12-07 14:52

This is a follow up to my initial question and I would like to present my findings and ask for corrections, ideas and insights. My findings (or rather interpretations) come

5条回答
  •  半阙折子戏
    2020-12-07 15:12

    Just add a new event on your main form:

    private void frmMain_Load(object sender, EventArgs e)
    {
      Application.ApplicationExit += new EventHandler(this.WhenItStopsDoThis);
    }
    
    private void WhenItStopsDoThis(object sender, EventArgs e)
    {
      //Program ended. Do something here.
    }
    

提交回复
热议问题