我有一个WPF应用程序,关闭应用程序后,其进程
app.exe *32
仍在任务管理器的进程列表中运行。
我需要关闭它,因为当我编辑代码时出现以下错误 -
Unable to copy file "obj\x86\Release\frontEndTest.exe" to "bin\Release\app.exe". The process cannot access the file 'bin\Release\app.exe' because it is being used by another process.
但是,通过将我的Assembly.cs
更改为-,该解决方案对我不起作用
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
我想也许如果我要找到
Window closed
事件并在事件中放置类似 -
Process.GetCurrentProcess().Kill();
的内容,这样当用户通过表单右上角的红色
'x'
按钮关闭应用程序时,就会出现这样的情况也许杀死进程?
首先,在调试器中附加它:
现在打开主题列表:
双击您在此处看到的
每个线程:
您将被带到线程当前正在执行的操作:
这就是阻止应用程序关闭的原因。必须退出该循环才能让应用程序退出(或者,将
Thread.IsBackground
设置为
true
)。
Terminates this process and gives the underlying operating system the specified exit code.
成功完成后返回0。