forked from cmliu/SubsCheck-Win-GUI
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (50 loc) · 1.97 KB
/
Program.cs
File metadata and controls
56 lines (50 loc) · 1.97 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
48
49
50
51
52
53
54
55
56
using System;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using subs_check.win.gui.Properties;
namespace subs_check.win.gui
{
static class Program
{
// 定义一个全局唯一的标识符,使用项目名称作为互斥体的名称
private static string appMutexName = "sinspired/SubsCheck-Win-GUI";
private static Mutex mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
// 尝试创建一个命名互斥体,如果已存在,则获取它
bool createdNew;
mutex = new Mutex(true, appMutexName, out createdNew);
if (!createdNew)
{
// 如果互斥体已存在(即程序已在运行),则终止当前实例
MessageBox.Show("应用程序已经在运行中。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
////启动时检查更新
////AutoUpdater.Mandatory = true;
////AutoUpdater.UpdateMode = Mode.Forced;
//AutoUpdater.SetOwner(MainGui.ActiveForm);
//AutoUpdater.Icon = Resources.download;
//AutoUpdater.ShowRemindLaterButton = false;
//AutoUpdater.ReportErrors = true;
//AutoUpdater.HttpUserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";
//AutoUpdater.Start("https://gh.39.al/raw.githubusercontent.com/sinspired/subsCheck-Win-GUI/master/update.xml");
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainGui());
}
finally
{
// 确保释放互斥体
mutex.ReleaseMutex();
}
}
}
}