0

I need to terminate a running WPF application (e.g. wpf.exe). This app however did override the OnClosing event by doing the following

protected override void OnClosing(CancelEventArgs e)
{      
    e.Cancel = true;
}

I tried to do "taskkill /f /im wpf.exe" but it still doesn't terminate it. How can I force terminate this app?

1 Answers1

1

rather than doing it

    protected override void OnClosing(CancelEventArgs e)
{      
    e.Cancel = true;
}

try

void Window_Closing(System.ComponentModel.CancelEventArgs e)
{
    IClosing context = DataContext as IClosing;
    if (context != null)
    {
        e.Cancel = !context.OnClosing();
    }
}
DeshDeep Singh
  • 1,817
  • 2
  • 23
  • 43