Skip to content

Commit 94ad6a1

Browse files
committed
#158 .NET Call SessionStart and SessionEnd on Register,UnRegister and Process Exit
1 parent 26c0d7f commit 94ad6a1

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Source/Platforms/Console/ExceptionlessExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ public static class ExceptionlessExtensions {
1111
/// </summary>
1212
/// <param name="client">The ExceptionlessClient.</param>
1313
public static void Register(this ExceptionlessClient client) {
14+
client.Configuration.UseSingleSessionPlugin();
1415
client.Startup();
16+
client.SubmitSessionStart();
1517

1618
// make sure that queued events are sent when the app exits
1719
client.RegisterOnProcessExitHandler();
@@ -24,11 +26,17 @@ public static void Register(this ExceptionlessClient client) {
2426
public static void Unregister(this ExceptionlessClient client) {
2527
client.Shutdown();
2628
client.UnregisterOnProcessExitHandler();
29+
client.SubmitSessionEnd();
30+
client.ProcessQueue();
2731
}
2832

2933
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
30-
if (_onProcessExit == null)
31-
_onProcessExit = (sender, args) => client.ProcessQueue();
34+
if (_onProcessExit == null) {
35+
_onProcessExit = (sender, args) => {
36+
client.SubmitSessionEnd();
37+
client.ProcessQueue();
38+
};
39+
}
3240

3341
try {
3442
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;

Source/Platforms/Windows/ExceptionlessWindowsExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static class ExceptionlessWindowsExtensions {
1717
public static void Register(this ExceptionlessClient client, bool showDialog = true) {
1818
client.Configuration.UseSingleSessionPlugin();
1919
client.Startup();
20+
client.SubmitSessionStart();
2021
client.RegisterApplicationThreadExceptionHandler();
2122

2223
// make sure that queued events are sent when the app exits
@@ -39,6 +40,9 @@ public static void Unregister(this ExceptionlessClient client) {
3940
client.UnregisterOnProcessExitHandler();
4041

4142
client.SubmittingEvent -= OnSubmittingEvent;
43+
44+
client.SubmitSessionEnd();
45+
client.ProcessQueue();
4246
}
4347

4448
private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
@@ -52,8 +56,12 @@ private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e)
5256
}
5357

5458
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
55-
if (_onProcessExit == null)
56-
_onProcessExit = (sender, args) => client.ProcessQueue();
59+
if (_onProcessExit == null) {
60+
_onProcessExit = (sender, args) => {
61+
client.SubmitSessionEnd();
62+
client.ProcessQueue();
63+
};
64+
}
5765

5866
try {
5967
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;

Source/Platforms/Wpf/ExceptionlessWpfExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static class ExceptionlessWpfExtensions {
1818
public static void Register(this ExceptionlessClient client, bool showDialog = true) {
1919
client.Configuration.UseSingleSessionPlugin();
2020
client.Startup();
21+
client.SubmitSessionStart();
2122
client.RegisterApplicationThreadExceptionHandler();
2223
client.RegisterApplicationDispatcherUnhandledExceptionHandler();
2324

@@ -42,6 +43,9 @@ public static void Unregister(this ExceptionlessClient client) {
4243
client.UnregisterOnProcessExitHandler();
4344

4445
client.SubmittingEvent -= OnSubmittingEvent;
46+
47+
client.SubmitSessionEnd();
48+
client.ProcessQueue();
4549
}
4650

4751
private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
@@ -62,8 +66,12 @@ private static bool ShowDialog(EventSubmittingEventArgs e) {
6266
}
6367

6468
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
65-
if (_onProcessExit == null)
66-
_onProcessExit = (sender, args) => client.ProcessQueue();
69+
if (_onProcessExit == null) {
70+
_onProcessExit = (sender, args) => {
71+
client.SubmitSessionEnd();
72+
client.ProcessQueue();
73+
};
74+
}
6775

6876
try {
6977
AppDomain.CurrentDomain.ProcessExit -= _onProcessExit;

0 commit comments

Comments
 (0)