-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (35 loc) · 1.09 KB
/
Copy pathProgram.cs
File metadata and controls
41 lines (35 loc) · 1.09 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
using Avalonia;
using Avalonia.ReactiveUI;
using Pap.erNet.Utils;
namespace Pap.erNet;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
// 使用跨平台单例检测
using var singleInstance = new SingleInstanceHelper("c270d6ef-7197-4150-99b9-b4d3d330f9a0");
try
{
// 尝试获取单例锁
if (!singleInstance.TryAcquireLock())
{
// 已有实例在运行,退出
return;
}
var builder = BuildAvaloniaApp();
builder.StartWithClassicDesktopLifetime(args, Avalonia.Controls.ShutdownMode.OnExplicitShutdown);
}
catch (Exception ex)
{
LogHelper.WriteLogAsync($"启动异常::{ex.Message}>>>{ex.StackTrace}");
throw;
}
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UsePlatformDetect().WithInterFont().LogToTrace().UseReactiveUI();
}