forked from svejdo1/HostsSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
30 lines (27 loc) · 772 Bytes
/
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
using System;
using System.Threading;
using System.Windows.Forms;
namespace Barbar.HostsSwitcher {
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool createdNew = false;
Mutex mutex = null;
try {
mutex = new Mutex(true, "HostsSwitcher", out createdNew);
} catch {
}
if (mutex == null || !createdNew) {
MessageBox.Show("Another instance of HostsSwitcher is already running.", "Cannot start HostsSwitcher", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try {
Application.Run(new FormMain());
} finally {
mutex.Close();
}
}
}
}