How to exit all running threads?

后端 未结 6 1834
有刺的猬
有刺的猬 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:22

    This got the job done for me:

    Instead of using:

    Application.Exit() 
    

    which leaves other threads open, try using:

    Environment.Exit(Environment.ExitCode);
    

提交回复
热议问题