diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging')
| -rw-r--r-- | Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs index fc791ff4a..3409ffdc4 100644 --- a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs +++ b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs @@ -21,6 +21,7 @@ namespace Tango.Logging public class WpfGlobalExceptionTrapper : IGlobalExceptionTrapper { private DateTime _lastGlobalExceptionTime = DateTime.Now.AddMinutes(-1); + private Application _app; /// <summary> /// Occurs when the global exception trapper has detected an unhandled exception. @@ -33,6 +34,7 @@ namespace Tango.Logging /// <param name="app">The application.</param> public void Initialize(Application app) { + _app = app; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; app.Dispatcher.UnhandledException += Dispatcher_UnhandledException; Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; @@ -40,6 +42,17 @@ namespace Tango.Logging } /// <summary> + /// Use only when need to simulate application crash! + /// </summary> + public void Disable() + { + AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; + _app.Dispatcher.UnhandledException -= Dispatcher_UnhandledException; + Application.Current.DispatcherUnhandledException -= Current_DispatcherUnhandledException; + TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException; + } + + /// <summary> /// Handles the UnobservedTaskException event of the TaskScheduler control. /// </summary> /// <param name="sender">The source of the event.</param> |
