问题描述
这与这里提出的问题略有相关,但答案不适用于我的情况,因为我没有使用线程:
This is slightly related to the question asked here yet the answer does not apply to my case as I am not using threads:
我已将我的一个 WinForm 应用程序转换为 WPF 应用程序,除了将几个单词更改为 WPF/C# 4.0 等效项(MessageBoxButtons 到 MessageBoxButton,为什么一个字母不同?)之外,不需要做任何大动作.
I have converted one of my WinForm application to a WPF application, nothing drastic needed to be done except for change a few words to the WPF/C# 4.0 equivalents (MessageBoxButtons to MessageBoxButton, why the one letter difference?).
无论如何,如果我通过调试器运行应用程序,它运行良好,直到我用X"关闭它为止.窗口右上角的按钮.应用程序窗口关闭,但我注意到调试器仍然显示停止图标,检查任务管理器确认它仍在运行.
Anyway, if I run the application through the debugger it runs fine until I come to close it with the "X" button to the top right of the window. The application window closes but I noticed that the debugger still shows the stop icon, checking in the Task Manager confirms it is still running.
我没有在后台运行任何其他线程,所以我知道它不会等待别的东西.
I am not running any other threads in the background so I know it's not waiting for something else.
我刚刚开始使用 WPF,但我认为当用户关闭应用程序时,它应该只是...关闭?
I've only just started with WPF but I assumed that when the user closes the application then it should just...close?
感谢您的帮助!
推荐答案
你的 关机模式?如果它是明确的,那是因为您没有明确关闭.如果是主窗口,那是因为您没有将主窗口分配给 Application.MainWindow
.
What is your shutdown mode? If it's explicit, then it's because you're not explicitly shutting down. If it's main window, it's because you've not assigned the main window to Application.MainWindow
.
这篇关于关闭后 WPF 应用程序仍在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!