forked from florentbr/SeleniumBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnhandledException.cs
More file actions
34 lines (26 loc) · 1.04 KB
/
UnhandledException.cs
File metadata and controls
34 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Selenium.Internal;
using System;
using System.Threading;
namespace Selenium.Core {
static class UnhandledException {
private static UnhandledExceptionEventHandler _callback = null;
private static Thread _thread = null;
public static void Initialize() {
if (_callback != null)
return;
_callback = new UnhandledExceptionEventHandler(On_UnhandledException);
AppDomain.CurrentDomain.UnhandledException += _callback;
}
private static void On_UnhandledException(object sender, UnhandledExceptionEventArgs ex_arg) {
if (ex_arg.ExceptionObject is ThreadAbortException)
return;
//Display the exception message box on another thread
_thread = new Thread(new ParameterizedThreadStart((ex) =>
ExceptionDialog.ShowDialog((Exception)ex)
));
_thread.IsBackground = true;
SysWaiter.Signal();
_thread.Start(ex_arg.ExceptionObject);
}
}
}