我有一个 WPF/C# 4.0 应用程序,它有一个应用程序文件 XAML,它是:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="XXX.App"
Startup="Application_Startup"
Exit="Application_Exit"
>
<Application.Resources>
</Application.Resources>
它的退出方法是:
//it seems that it never passes here. Transferred to MainAppWindow_WindowClosing
private void Application_Exit(object sender, ExitEventArgs e)
{
this.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
}
当应用程序用户关闭它时,它永远不会传入这段代码。它应该以这种方式工作吗?难道我做错了什么?