Mercurial > servermonitor
comparison ServerMonitor/Program.cs @ 8:052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Sat, 09 Mar 2019 20:14:03 -0500 |
parents | 3e1a2131f897 |
children | 68d7834dc28e |
comparison
equal
deleted
inserted
replaced
7:8486ab7d2357 | 8:052aa62cb42a |
---|---|
6 | 6 |
7 namespace ServerMonitorApp | 7 namespace ServerMonitorApp |
8 { | 8 { |
9 static class Program | 9 static class Program |
10 { | 10 { |
11 static Mutex mutex = new Mutex(true, "c681570e-dff4-45fa-bdca-d8ca928a0f8a"); | |
12 | |
11 /// <summary> | 13 /// <summary> |
12 /// The main entry point for the application. | 14 /// The main entry point for the application. |
13 /// </summary> | 15 /// </summary> |
14 [STAThread] | 16 [STAThread] |
15 static void Main() | 17 static void Main() |
16 { | 18 { |
17 Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); | 19 if (mutex.WaitOne(TimeSpan.Zero, true)) |
18 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); | 20 { |
19 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); | 21 Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); |
22 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); | |
23 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); | |
20 | 24 |
21 Application.EnableVisualStyles(); | 25 Application.EnableVisualStyles(); |
22 Application.SetCompatibleTextRenderingDefault(false); | 26 Application.SetCompatibleTextRenderingDefault(false); |
23 Application.Run(new ServerSummaryForm()); | 27 Application.Run(new ServerSummaryForm()); |
28 } | |
29 else | |
30 { | |
31 Win32Helpers.PostMessage( | |
32 (IntPtr)Win32Helpers.HWND_BROADCAST, | |
33 Win32Helpers.WM_SHOWMONITOR, | |
34 IntPtr.Zero, | |
35 IntPtr.Zero); | |
36 } | |
24 } | 37 } |
25 | 38 |
26 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) | 39 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) |
27 { | 40 { |
28 //if (!System.Diagnostics.Debugger.IsAttached) | 41 //if (!System.Diagnostics.Debugger.IsAttached) |