3
3
using System . IO ;
4
4
using System . Windows . Forms ;
5
5
using Exceptionless . Models . Collections ;
6
+ using Exceptionless . Plugins ;
6
7
using Tester ;
7
8
8
9
namespace Exceptionless . SampleWindows {
9
10
public partial class MainForm : Form {
10
11
public MainForm ( ) {
11
12
InitializeComponent ( ) ;
12
13
ExceptionlessClient . Default . SubmittingEvent += OnSubmittingEvent ;
14
+ ExceptionlessClient . Default . SubmittedEvent += OnSubmittedEvent ;
13
15
ExceptionlessClient . Default . Configuration . Settings . Changed += SettingsOnChanged ;
14
16
}
15
17
@@ -19,7 +21,7 @@ private void SettingsOnChanged(object sender, ChangedEventArgs<KeyValuePair<stri
19
21
return ;
20
22
}
21
23
22
- logTextBox . AppendText ( "Configuration Updated." ) ;
24
+ logTextBox . AppendText ( "\r \n Configuration Updated." ) ;
23
25
}
24
26
25
27
private void OnSubmittingEvent ( object sender , EventSubmittingEventArgs e ) {
@@ -33,13 +35,17 @@ private void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
33
35
e . Event . Tags . Add ( "Important" ) ;
34
36
35
37
if ( ! String . IsNullOrEmpty ( e . Event . ReferenceId ) )
36
- logTextBox . AppendText ( $ "Submitting Event: { e . Event . ReferenceId } { Environment . NewLine } ") ;
38
+ logTextBox . AppendText ( $ "\r \n Submitting Event: { e . Event . ReferenceId } { Environment . NewLine } ") ;
37
39
else
38
- logTextBox . AppendText ( "Submitting Event" ) ;
40
+ logTextBox . AppendText ( "\r \n Submitting Event" ) ;
39
41
40
42
statusLabel . Text = "Submitting Message" ;
41
43
}
42
44
45
+ private void OnSubmittedEvent ( object sender , EventSubmittedEventArgs e ) {
46
+ statusLabel . Text = String . Empty ;
47
+ }
48
+
43
49
private void generateExceptionToolStripMenuItem_Click ( object sender , EventArgs e ) {
44
50
//try to open a file
45
51
string buffer = File . ReadAllText ( "somefile2.txt" ) ;
@@ -49,23 +55,29 @@ private void processQueueToolStripMenuItem_Click(object sender, EventArgs e) {
49
55
ExceptionlessClient . Default . ProcessQueueAsync ( ) ;
50
56
}
51
57
52
- private void randomExceptionToolStripMenuItem_Click ( object sender , EventArgs e ) {
53
- string path = Path . GetRandomFileName ( ) ;
58
+ private void OnRandomExceptionMenuItemClick ( object sender , EventArgs e ) {
59
+ File . ReadAllText ( Path . GetRandomFileName ( ) ) ;
60
+ }
54
61
55
- //try to open a file
56
- //simulate filenotfound exception
57
- string buffer = File . ReadAllText ( path ) ;
62
+ private void OnAttemptDeadlockMenuItemClick ( object sender , EventArgs e ) {
63
+ for ( int i = 0 ; i < 10 ; i ++ ) {
64
+ for ( int i2 = 0 ; i2 < 5 ; i2 ++ ) {
65
+ new Exception ( "test for deadlock" ) . ToExceptionless ( ) . Submit ( ) ;
66
+ }
67
+
68
+ var contextData = new ContextData ( ) ;
69
+ contextData . MarkAsUnhandledError ( ) ;
70
+ contextData . SetSubmissionMethod ( "OnAttemptDeadlockMenuItemClick" ) ;
71
+
72
+ new ApplicationException ( "Attempt to deadlock:" + i ) . ToExceptionless ( contextData ) . SetManualStackingInfo ( new Dictionary < string , string > { { "iteration" , i . ToString ( ) } } ) . Submit ( ) ;
73
+ }
58
74
}
59
75
60
76
private void toolStripMenuItem1_Click ( object sender , EventArgs e ) {
61
77
try {
62
- //try to open a file
63
- string buffer = File . ReadAllText ( "somefile.txt" ) ;
64
- //simulate filenotfound exception
65
- //throw new System.IO.FileNotFoundException("The file could not be found.", "SomeFile.txt");
78
+ File . ReadAllText ( "somefile.txt" ) ;
66
79
} catch ( Exception ex ) {
67
- throw new ApplicationException (
68
- "An ev has occurred and I have wrapped it inside of this ApplicationException." , ex ) ;
80
+ throw new ApplicationException ( "An ev has occurred and I have wrapped it inside of this ApplicationException." , ex ) ;
69
81
}
70
82
}
71
83
@@ -86,11 +98,8 @@ private void multipleExceptionsToolStripMenuItem_Click(object sender, EventArgs
86
98
87
99
decimal count = multiple . NumericUpDown . Value ;
88
100
89
- for ( int i = 0 ; i < count ; i ++ ) {
101
+ for ( int i = 0 ; i < count ; i ++ )
90
102
new ApplicationException ( "Multiple Crash Test." ) . ToExceptionless ( ) . SetUserDescription ( "[email protected] " , "Testing multiple crash reports. " + i ) . Submit ( ) ;
91
- //r.Description = "Testing multiple crash reports.";
92
- //r.EmailAddress = "[email protected] ";
93
- }
94
103
}
95
104
96
105
private void showFilterFormToolStripMenuItem_Click ( object sender , EventArgs e ) {
0 commit comments