mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
feat: 仅允许单实例同时运行
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -45,13 +46,19 @@ public partial class App : PrismApplication
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
var mutex = new Mutex(true, "Global\\DownKyi", out var createdNew);
|
||||
if (!createdNew)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.Exit += OnExit!;
|
||||
AppLife = desktop;
|
||||
}
|
||||
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user