From 8d9212c7c5b9d7564fcd4ac533c4e77a3f9f4209 Mon Sep 17 00:00:00 2001 From: Emilia <emilia@jumpsca.re> Date: Tue, 18 Mar 2025 11:55:06 +0200 Subject: [PATCH] mutex --- .idea/.idea.Blacklight/.idea/avalonia.xml | 1 + Blacklight.Desktop/Program.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.idea/.idea.Blacklight/.idea/avalonia.xml b/.idea/.idea.Blacklight/.idea/avalonia.xml index 2afc772..b0754ad 100644 --- a/.idea/.idea.Blacklight/.idea/avalonia.xml +++ b/.idea/.idea.Blacklight/.idea/avalonia.xml @@ -24,6 +24,7 @@ <entry key="Blacklight/Views/Utility/MarkdownText.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/Views/ClientView.axaml" value="Blacklight/Blacklight.csproj" /> <entry key="Blacklight/Views/Views/SettingsView.axaml" value="Blacklight/Blacklight.csproj" /> + <entry key="Blacklight/Views/Windows/CreateChannelView.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/Windows/CreateChannelWindow.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> </map> </option> diff --git a/Blacklight.Desktop/Program.cs b/Blacklight.Desktop/Program.cs index 3dfca23..47254d0 100644 --- a/Blacklight.Desktop/Program.cs +++ b/Blacklight.Desktop/Program.cs @@ -6,14 +6,20 @@ namespace Blacklight.Desktop; sealed class Program { + private static Mutex _mutex = new Mutex(true, "{BFB1CB9E-78E6-4CC4-AB51-AD561BE8E21A}"); // 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) { - BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + if (_mutex.WaitOne(TimeSpan.Zero, true)) + { + + BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + _mutex.ReleaseMutex(); + } } // Avalonia configuration, don't remove; also used by visual designer. -- GitLab