diff --git a/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj
index 709517faa..8c2b575bd 100644
--- a/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj
+++ b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj
@@ -1,7 +1,7 @@
-
+
@@ -12,4 +12,4 @@
-
\ No newline at end of file
+
diff --git a/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs b/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs
index 159588171..1c9fb073d 100644
--- a/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs
+++ b/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
-using System.Threading;
using System.Threading.Tasks;
+using AsyncKeyedLock;
using MaterialDesignThemes.Wpf;
using Microsoft.Win32;
using Stylet;
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Framework;
public class DialogManager(IViewManager viewManager) : IDisposable
{
- private readonly SemaphoreSlim _dialogLock = new(1, 1);
+ private readonly AsyncNonKeyedLocker _dialogLock = new();
public async ValueTask ShowDialogAsync(DialogScreen dialogScreen)
{
@@ -34,16 +34,11 @@ void OnScreenClosed(object? closeSender, EventArgs closeArgs)
dialogScreen.Closed += OnScreenClosed;
}
- await _dialogLock.WaitAsync();
- try
+ using (await _dialogLock.LockAsync())
{
await DialogHost.Show(view, OnDialogOpened);
return dialogScreen.DialogResult;
}
- finally
- {
- _dialogLock.Release();
- }
}
public string? PromptSaveFilePath(string filter = "All files|*.*", string defaultFilePath = "")