C# Winform The process still on Windows Task list manager after close programme

前端 未结 6 1784
我在风中等你
我在风中等你 2021-01-16 21:46

why The process still on Windows Task list manager after close programme ?

i use login Form.cs

 [STAThread]
        static void Main()
        {
             


        
6条回答
  •  一个人的身影
    2021-01-16 22:43

    this.Hide()
    

    doesn`t kill the window.

    So it remains hidden and process remains in memory. this.Close() closes the window and removes its object from memory.

    It is better to do something like this:

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        var l = new Login();
        l.ShowDialog();
        if(l.Passed)
           Application.Run(new Login());
    }
    

    And implement Passed property inside login window.

    By the way, do you have any multithreading inside? It is another source of errors of this type.

提交回复
热议问题