Widow – Diff between revs 6 and 19
?pathlinks?
Rev 6 | Rev 19 | |||
---|---|---|---|---|
1 | using System; |
1 | using System; |
|
- | 2 | using System.Threading; |
||
2 | using System.Windows.Forms; |
3 | using System.Windows.Forms; |
|
3 | |
4 | |
|
4 | namespace Widow |
5 | namespace Widow |
|
5 | { |
6 | { |
|
6 | internal class Program : IDisposable |
7 | internal class Program : IDisposable |
|
7 | { |
8 | { |
|
8 | #region Static Fields and Constants |
9 | #region Static Fields and Constants |
|
- | 10 | |
||
- | 11 | private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid); |
||
9 | |
12 | |
|
10 | private static Form _form; |
13 | private static Form _form; |
|
11 | |
14 | |
|
12 | #endregion |
15 | #endregion |
|
13 | |
16 | |
|
14 | #region Constructors, Destructors and Finalizers |
17 | #region Constructors, Destructors and Finalizers |
|
15 | |
18 | |
|
16 | public void Dispose() |
19 | public void Dispose() |
|
17 | { |
20 | { |
|
18 | _form?.Dispose(); |
21 | _form?.Dispose(); |
|
19 | _form = null; |
22 | _form = null; |
|
20 | } |
23 | } |
|
21 | |
24 | |
|
22 | #endregion |
25 | #endregion |
|
23 | |
26 | |
|
24 | #region Private Methods |
27 | #region Private Methods |
|
25 | |
28 | |
|
26 | /// <summary> |
29 | /// <summary> |
|
27 | /// The main entry point for the application. |
30 | /// The main entry point for the application. |
|
28 | /// </summary> |
31 | /// </summary> |
|
29 | [STAThread] |
32 | [STAThread] |
|
30 | private static void Main() |
33 | private static void Main() |
|
31 | { |
34 | { |
|
32 | Application.EnableVisualStyles(); |
35 | if (Mutex.WaitOne(TimeSpan.Zero, true)) |
|
- | 36 | { |
||
33 | Application.SetCompatibleTextRenderingDefault(false); |
37 | Application.SetCompatibleTextRenderingDefault(false); |
|
34 | _form = new MainForm(); |
38 | _form = new MainForm(); |
|
35 | Application.Run(); |
39 | Application.Run(); |
|
- | 40 | Mutex.ReleaseMutex(); |
||
- | 41 | return; |
||
- | 42 | } |
||
- | 43 | |
||
- | 44 | // Foreground current other application window. |
||
- | 45 | Natives.PostMessage( |
||
- | 46 | (IntPtr) Natives.HWND_BROADCAST, |
||
- | 47 | Natives.WM_SHOWME, |
||
- | 48 | IntPtr.Zero, |
||
- | 49 | IntPtr.Zero); |
||
36 | } |
50 | } |
|
37 | |
51 | |
|
38 | #endregion |
52 | #endregion |
|
39 | } |
53 | } |
|
40 | } |
54 | } |
|
41 | |
55 | |
|
42 |
|
56 |
|
|
43 | |
57 | |
|
44 | |
58 | |
|
45 | |
59 | |