-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
63 lines (51 loc) · 2.2 KB
/
Program.cs
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using InspectorGadgetGui.ProcessCommunication;
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace InspectorGadgetGui
{
static class Program
{
static Program()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
AppDomain currentDomain = default(AppDomain);
currentDomain = AppDomain.CurrentDomain;
// Handler for unhandled exceptions.
currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;
// Handler for exceptions in threads behind forms.
System.Windows.Forms.Application.ThreadException += GlobalThreadExceptionHandler;
try
{
ProcessCommunicator.checkCommunication();
MainForm mainForm = MainForm.getInstance();
Application.Run(mainForm);
ProcessCommunicator.terminateProcess();
}
catch (Exception e)
{
MessageBox.Show("An error happened launching this application: \r\n\r\n" + e.Message + "\r\n" + e.StackTrace, "Inspectorgadget", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = default(Exception);
ex = (Exception)e.ExceptionObject;
MessageBox.Show("An error happened launching this application: \r\n\r\n" + ex.Message + "\r\n" + ex.StackTrace, "Inspectorgadget", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private static void GlobalThreadExceptionHandler(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Exception ex = default(Exception);
ex = e.Exception;
MessageBox.Show("An error happened launching this application: \r\n\r\n" + ex.Message + "\r\n" + ex.StackTrace, "Inspectorgadget", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}