How to exit all running threads?

后端 未结 6 1824
有刺的猬
有刺的猬 2020-12-02 20:02

The following code does not exit the application. How can I exit the application and make sure all the running threads are closed?

foreach (Form form in Appl         


        
6条回答
  •  春和景丽
    2020-12-02 20:29

    This should work for all threads you opened.

    protected override void OnExiting(Object sender, EventArgs args)
    {
        base.OnExiting(sender, args);
        Environment.Exit(Environment.ExitCode);
    }
    

提交回复
热议问题