WPF专业编程指南 - DispatcherUnhandledException

时间:2015-04-30 12:12:52   收藏:0   阅读:648

WPF的Application类中有一个事件:DispatcherUnhandledException,在应用程序未对其中的异常加以处理的情况下发生,从而为应用程序把好最后的大门

技术分享
 1 namespace Chapter1_WpfApplication1
 2 {
 3     /// <summary>
 4     /// Interaction logic for App.xaml
 5     /// </summary>
 6     public partial class App : Application
 7     {
 8         protected override void OnStartup(StartupEventArgs e)
 9         {
10             base.OnStartup(e);
11 
12             this.DispatcherUnhandledException += App_DispatcherUnhandledException;
13         }
14 
15         void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
16         {
17             throw new NotImplementedException();
18         }
19     }
20 }
View Code

很显然,这可以作为后备手段,但是不能依靠它主动解决问题,还是需要良好的捕捉异常的习惯

原文:http://www.cnblogs.com/cinlap/p/4468257.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!