5
5
using System . Threading . Tasks ;
6
6
using System . Windows ;
7
7
using Exceptionless . Models . Collections ;
8
+ using Exceptionless . Plugins ;
8
9
9
10
namespace Exceptionless . SampleWpf {
10
11
public partial class MainWindow : Window {
12
+ private const string FORCE_CLOSE_APPLICATION_KEY = "ForceCloseApplication" ;
13
+
11
14
public MainWindow ( ) {
12
15
InitializeComponent ( ) ;
13
16
14
17
ExceptionlessClient . Default . SubmittingEvent += OnSubmittingEvent ;
18
+ ExceptionlessClient . Default . SubmittedEvent += OnSubmittedEvent ;
15
19
ExceptionlessClient . Default . Configuration . Settings . Changed += SettingsOnChanged ;
16
20
}
17
-
21
+
18
22
private void SettingsOnChanged ( object sender , ChangedEventArgs < KeyValuePair < string , string > > args ) {
19
23
WriteLog ( "Configuration updated." ) ;
20
24
}
@@ -29,6 +33,13 @@ private void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
29
33
else
30
34
WriteLog ( "Submitting Event" ) ;
31
35
}
36
+
37
+ private void OnSubmittedEvent ( object sender , EventSubmittedEventArgs e ) {
38
+ if ( e . PluginContextData . ContainsKey ( FORCE_CLOSE_APPLICATION_KEY ) ) {
39
+ WriteLog ( "Shutting down application" ) ;
40
+ Application . Current . Shutdown ( ) ;
41
+ }
42
+ }
32
43
33
44
private void WriteLog ( string message ) {
34
45
if ( logTextBox . Dispatcher . CheckAccess ( ) )
@@ -71,6 +82,15 @@ private void OnImportDemoReports(object sender, RoutedEventArgs e) {}
71
82
private void OnProcessQueue ( object sender , RoutedEventArgs e ) {
72
83
ExceptionlessClient . Default . ProcessQueueAsync ( ) ;
73
84
}
85
+
86
+ private void OnGenerateExceptionAndClose ( object sender , RoutedEventArgs e ) {
87
+ try {
88
+ throw new Exception ( "TEST!" ) ;
89
+ } catch ( Exception ex ) {
90
+ var pluginContextData = new ContextData { { FORCE_CLOSE_APPLICATION_KEY , true } } ;
91
+ ex . ToExceptionless ( pluginContextData ) . Submit ( ) ;
92
+ }
93
+ }
74
94
75
95
private void OnGenerateThreadException ( object sender , RoutedEventArgs e ) {
76
96
var t = new Thread ( ( ) => {
0 commit comments