【问题标题】:Kill Process in task manager using WPF with hosted Winform使用 WPF 和托管 Winform 在任务管理器中终止进程
【发布时间】:2017-10-17 18:11:29
【问题描述】:

我有一个 WPF 应用程序,它在用户控件中托管一个 Winform 表单。当我关闭应用程序时,整个 wpf 应用程序仍然存在于 Windows 任务管理器的进程中。我可能有办法通过查看整个代码来解决这个问题,但我的时间有限。我想知道在 WPF 应用程序关闭时是否可以在任务管理器中终止整个应用程序的进程。我该怎么做?

【问题讨论】:

    标签: c# .net wpf winforms


    【解决方案1】:

    我找到了一种通过添加来杀死进程的方法

          protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
    
            Environment.Exit(0);
    
        }
    

    在MainWindow.cs代码后面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-05
      相关资源
      最近更新 更多