From ad24aeffed5a4866d1c5cd50ad9825782b0d67ab Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 9 Jun 2025 14:48:16 +0800 Subject: [PATCH] Use ConcurrentDictionary --- Flow.Launcher/Notification.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs index 76a9d2adc..deb5442a4 100644 --- a/Flow.Launcher/Notification.cs +++ b/Flow.Launcher/Notification.cs @@ -1,9 +1,9 @@ -using Flow.Launcher.Infrastructure; -using Microsoft.Toolkit.Uwp.Notifications; -using System; -using System.Collections.Generic; +using System; +using System.Collections.Concurrent; using System.IO; using System.Windows; +using Flow.Launcher.Infrastructure; +using Microsoft.Toolkit.Uwp.Notifications; namespace Flow.Launcher { @@ -13,7 +13,7 @@ namespace Flow.Launcher internal static bool legacy = !Win32Helper.IsNotificationSupported(); - private static readonly Dictionary _notificationActions = new(); + private static readonly ConcurrentDictionary _notificationActions = new(); internal static void Install() { @@ -120,7 +120,7 @@ namespace Flow.Launcher .AddButton(buttonText, ToastActivationType.Background, guid) .AddAppLogoOverride(new Uri(Icon)) .Show(); - _notificationActions.Add(guid, buttonAction); + _notificationActions.AddOrUpdate(guid, buttonAction, (key, oldValue) => buttonAction); } catch (InvalidOperationException e) {