forked from sbozzie/test-intel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (43 loc) · 1.73 KB
/
Copy pathProgram.cs
File metadata and controls
47 lines (43 loc) · 1.73 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
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Threading;
using System.Windows.Forms;
namespace TestIntelReporter {
static class Program {
/// <summary>
/// Global "application name" to maintain single instance
/// operation.
/// </summary>
internal const string mutexName = "{8E5BA95B-79CC-4F9A-9CF1-88297BD8FEA7}";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
bool createdMutex;
var updateCheck = new UpdateCheck();
updateCheck.CheckUri = "http://minecraft.etherealwake.com/updates.xml";
updateCheck.Start();
using (var mutex = new Mutex(true, mutexName, out createdMutex)) {
if (createdMutex) {
// Created the mutex, so we are the first instance
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var mainform = new MainForm();
Application.Run(mainform);
GC.KeepAlive(mutex);
} else {
// Not the first instance, so send a signal to wake up the other
try {
var message = NativeMethods.RegisterWindowMessage(mutexName);
if (message != 0) {
NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST,
message, IntPtr.Zero, IntPtr.Zero);
}
} catch {
// We really don't care, we're quitting anyway
}
}
}
}
}
}