应用程序未正确结束并且 运行 在后台

Application not ending properly and running in the background

我有一个简单的 wpf 应用程序。但它使用 CefSharp 在基于 chrome 的浏览器中打开一些链接。我发现一旦应用程序的主要 window 关闭,它就会从 UI 关闭,但它仍在后台运行。

我尝试添加额外的代码来强制关闭它。但没有希望。我认为 cefsharp 的某些组件未正确结束。但不确定到底出了什么问题。

也使用了下面的代码和其他一些片段

protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);


            foreach (Window w in App.Current.Windows)
            {
                if (w.DataContext != this)
                    w.Close();
            }
            Application.Current.Shutdown();
        }

正如我在评论中所说,尝试:Environment.Exit(0);

如果这不起作用,请从 Cef.Shutdown();

开始

If you REALLY need it to close out you can also use Environment.Exit() but it is not graceful at all (more like ending the process).