Skip to content

Commit 7021e45

Browse files
committed
Added process onexit queue processing to .net standard 1.5
1 parent 04dded0 commit 7021e45

File tree

4 files changed

+3
-72
lines changed

4 files changed

+3
-72
lines changed

src/Exceptionless/Extensions/ExceptionlessClientExtensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
3030

3131
#if NETSTANDARD1_5 || NET45
3232
client.RegisterAppDomainUnhandledExceptionHandler();
33-
#endif
34-
#if NET45
33+
3534
// make sure that queued events are sent when the app exits
3635
client.RegisterOnProcessExitHandler();
3736
#endif
@@ -48,8 +47,6 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
4847
public static void Shutdown(this ExceptionlessClient client) {
4948
#if NETSTANDARD1_5 || NET45
5049
client.UnregisterAppDomainUnhandledExceptionHandler();
51-
#endif
52-
#if NET45
5350
client.UnregisterOnProcessExitHandler();
5451
#endif
5552
client.UnregisterTaskSchedulerUnobservedTaskExceptionHandler();
@@ -318,9 +315,7 @@ public static void UnregisterAppDomainUnhandledExceptionHandler(this Exceptionle
318315
AppDomain.CurrentDomain.UnhandledException -= _onAppDomainUnhandledException;
319316
_onAppDomainUnhandledException = null;
320317
}
321-
#endif
322318

323-
#if NET45
324319
private static EventHandler _onProcessExit;
325320
public static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
326321
if (_onProcessExit == null) {

src/Exceptionless/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"dependencies": {
187187
"Microsoft.CSharp": "4.0.1-rc2-24027",
188188
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final",
189-
"System.AppDomain": "2.0.8",
189+
"System.AppDomain": "2.0.9",
190190
"System.Collections": "4.0.11-rc2-24027",
191191
"System.Collections.Concurrent": "4.0.12-rc2-24027",
192192
"System.ComponentModel.TypeConverter": "4.0.1-rc2-24027",

src/Platforms/Exceptionless.Windows/ExceptionlessWindowsExtensions.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
namespace Exceptionless {
1010
public static class ExceptionlessWindowsExtensions {
11-
private static EventHandler _onProcessExit;
12-
1311
/// <summary>
1412
/// Reads configuration settings, configures various plugins and wires up to platform specific exception handlers.
1513
/// </summary>
@@ -23,9 +21,6 @@ public static void Register(this ExceptionlessClient client, bool showDialog = t
2321
client.SubmitSessionStart();
2422

2523
client.RegisterApplicationThreadExceptionHandler();
26-
27-
// make sure that queued events are sent when the app exits
28-
client.RegisterOnProcessExitHandler();
2924

3025
if (!showDialog)
3126
return;
@@ -41,7 +36,6 @@ public static void Register(this ExceptionlessClient client, bool showDialog = t
4136
public static void Unregister(this ExceptionlessClient client) {
4237
client.Shutdown();
4338
client.UnregisterApplicationThreadExceptionHandler();
44-
client.UnregisterOnProcessExitHandler();
4539

4640
client.SubmittingEvent -= OnSubmittingEvent;
4741

@@ -59,31 +53,5 @@ private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e)
5953
var dialog = new CrashReportForm(e.Client, e.Event);
6054
e.Cancel = dialog.ShowDialog() != DialogResult.OK;
6155
}
62-
63-
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
64-
if (_onProcessExit == null) {
65-
_onProcessExit = (sender, args) => {
66-
client.ProcessQueue();
67-
68-
if (client.Configuration.SessionsEnabled)
69-
client.SubmitSessionEnd();
70-
};
71-
}
72-
73-
try {
74-
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;
75-
AppDomain.CurrentDomain.ProcessExit += _onProcessExit;
76-
} catch (Exception ex) {
77-
client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessWindowsExtensions), ex, "An error occurred while wiring up to the process exit event.");
78-
}
79-
}
80-
81-
private static void UnregisterOnProcessExitHandler(this ExceptionlessClient client) {
82-
if (_onProcessExit == null)
83-
return;
84-
85-
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;
86-
_onProcessExit = null;
87-
}
8856
}
8957
}

src/Platforms/Exceptionless.Wpf/ExceptionlessWpfExtensions.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace Exceptionless {
1111
public static class ExceptionlessWpfExtensions {
12-
private static EventHandler _onProcessExit;
13-
1412
/// <summary>
1513
/// Reads configuration settings, configures various plugins and wires up to platform specific exception handlers.
1614
/// </summary>
@@ -26,9 +24,6 @@ public static void Register(this ExceptionlessClient client, bool showDialog = t
2624
client.RegisterApplicationThreadExceptionHandler();
2725
client.RegisterApplicationDispatcherUnhandledExceptionHandler();
2826

29-
// make sure that queued events are sent when the app exits
30-
client.RegisterOnProcessExitHandler();
31-
3227
if (!showDialog)
3328
return;
3429

@@ -44,8 +39,7 @@ public static void Unregister(this ExceptionlessClient client) {
4439
client.Shutdown();
4540
client.UnregisterApplicationThreadExceptionHandler();
4641
client.UnregisterApplicationDispatcherUnhandledExceptionHandler();
47-
client.UnregisterOnProcessExitHandler();
48-
42+
4943
client.SubmittingEvent -= OnSubmittingEvent;
5044

5145
client.ProcessQueue();
@@ -68,31 +62,5 @@ private static bool ShowDialog(EventSubmittingEventArgs e) {
6862
bool? result = dialog.ShowDialog();
6963
return result.HasValue && result.Value;
7064
}
71-
72-
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
73-
if (_onProcessExit == null) {
74-
_onProcessExit = (sender, args) => {
75-
client.ProcessQueue();
76-
77-
if (client.Configuration.SessionsEnabled)
78-
client.SubmitSessionEnd();
79-
};
80-
}
81-
82-
try {
83-
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;
84-
AppDomain.CurrentDomain.ProcessExit += _onProcessExit;
85-
} catch (Exception ex) {
86-
client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessWpfExtensions), ex, "An error occurred while wiring up to the process exit event.");
87-
}
88-
}
89-
90-
private static void UnregisterOnProcessExitHandler(this ExceptionlessClient client) {
91-
if (_onProcessExit == null)
92-
return;
93-
94-
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;
95-
_onProcessExit = null;
96-
}
9765
}
9866
}

0 commit comments

Comments
 (0)