mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-01-28 22:01:55 +00:00
Switched from SemaphoreSlim lock to AsyncNonKeyedLocker (#1184)
This commit is contained in:
committed by
GitHub
parent
12b590d9f9
commit
74f99b4e59
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncKeyedLock" Version="6.2.4" />
|
||||
<PackageReference Include="AsyncKeyedLock" Version="6.3.4" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.7" PrivateAssets="all" />
|
||||
<PackageReference Include="Gress" Version="2.1.1" />
|
||||
<PackageReference Include="JsonExtensions" Version="1.2.0" />
|
||||
@@ -12,4 +12,4 @@
|
||||
<PackageReference Include="YoutubeExplode" Version="6.3.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -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<T?> ShowDialogAsync<T>(DialogScreen<T> dialogScreen)
|
||||
{
|
||||
@@ -34,16 +34,11 @@ public class DialogManager(IViewManager viewManager) : IDisposable
|
||||
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 = "")
|
||||
|
||||
Reference in New Issue
Block a user