Application is still running in memory after Application.Exit() is called

后端 未结 4 1335
不思量自难忘°
不思量自难忘° 2020-12-31 12:19

The application I am building is still running in memory (checked in Task Manager) after it is closed using Application.Exit(). Because of this when I am runnin

4条回答
  •  感动是毒
    2020-12-31 12:25

    It seems that this is a Windows ap and you are calling System.Windows.Forms.Application.Exit() but there is a thread still running in the background. Have you tried

    Application.ExitThread();
    
    Environment.Exit();
    

    You could kill the process as Jonesy mentioned, passing in the process ID of the process if it is a separate application than the current running process.

    For that, you need to use the System.Diagnostics.Process namespace and loop through the currently running processes to get the right pid and then call kill on that pid.

提交回复
热议问题