|
1 | 1 | using System; |
2 | | -using System.Threading; |
3 | 2 | using System.Windows.Threading; |
4 | 3 | using Exceptionless.Dependency; |
5 | 4 | using Exceptionless.Plugins; |
6 | 5 | using Exceptionless.Logging; |
7 | 6 |
|
8 | 7 | namespace Exceptionless.Wpf.Extensions { |
9 | 8 | public static class ExceptionlessClientExtensions { |
10 | | - private static ThreadExceptionEventHandler _onApplicationThreadException; |
11 | | - |
12 | | - public static void RegisterApplicationThreadExceptionHandler(this ExceptionlessClient client) { |
13 | | - if (client == null) |
14 | | - throw new ArgumentNullException(nameof(client)); |
15 | | - |
16 | | - if (_onApplicationThreadException == null) |
17 | | - _onApplicationThreadException = (sender, args) => { |
18 | | - var contextData = new ContextData(); |
19 | | - contextData.MarkAsUnhandledError(); |
20 | | - contextData.SetSubmissionMethod("ApplicationThreadException"); |
21 | | - |
22 | | - args.Exception.ToExceptionless(contextData, client).Submit(); |
23 | | - }; |
24 | | - |
25 | | - try { |
26 | | - System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException; |
27 | | - System.Windows.Forms.Application.ThreadException += _onApplicationThreadException; |
28 | | - } catch (Exception ex) { |
29 | | - client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the application thread exception event."); |
30 | | - } |
31 | | - } |
32 | | - |
33 | | - public static void UnregisterApplicationThreadExceptionHandler(this ExceptionlessClient client) { |
34 | | - if (client == null) |
35 | | - throw new ArgumentNullException(nameof(client)); |
36 | | - |
37 | | - if (_onApplicationThreadException == null) |
38 | | - return; |
39 | | - |
40 | | - System.Windows.Forms.Application.ThreadException -= _onApplicationThreadException; |
41 | | - _onApplicationThreadException = null; |
42 | | - } |
43 | | - |
44 | 9 | private static DispatcherUnhandledExceptionEventHandler _onApplicationDispatcherUnhandledException; |
45 | 10 |
|
46 | 11 | public static void RegisterApplicationDispatcherUnhandledExceptionHandler(this ExceptionlessClient client) { |
|
0 commit comments