WPF应用程序仍然运行在后台关闭后, [英] WPF Application still runs in background after closing

查看:858
本文介绍了WPF应用程序仍然运行在后台关闭后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是稍微涉及到这里问这个问题还没有答案,因为我没有使用线程并不适用于我的情况:

This is slightly related to the question asked here yet the answer does not apply to my case as I am not using threads:

<一个href="http://stackoverflow.com/questions/1116133/my-wpf-app-still-running-if-i-open-another-window">WPF不正常关闭

我已经将我的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应用程序仍然运行在后台关闭后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆