Skip to content

Commit

Permalink
feat: 仅允许单实例同时运行
Browse files Browse the repository at this point in the history
  • Loading branch information
yaobiao131 committed Mar 5, 2024
1 parent bc5be4f commit adf5e5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion DownKyi/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit adf5e5c

Please sign in to comment.