From b9c563ca9158bdf420bf65fddce0efbf4bcd5b9c Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Thu, 10 Nov 2022 14:28:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=99=E9=80=9A=E7=9F=A5=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E5=A5=97=E4=B8=80=E5=B1=82=20Execute.OnUIThr?= =?UTF-8?q?ead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/2692 --- src/MeoAsstGui/Helper/ToastNotification.cs | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/MeoAsstGui/Helper/ToastNotification.cs b/src/MeoAsstGui/Helper/ToastNotification.cs index 4139ca1e07..e892982d1e 100644 --- a/src/MeoAsstGui/Helper/ToastNotification.cs +++ b/src/MeoAsstGui/Helper/ToastNotification.cs @@ -24,6 +24,7 @@ using System.Windows; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using Stylet; using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Win32; using Notification.Wpf; @@ -399,24 +400,27 @@ namespace MeoAsstGui { try { - if (_buttonSystemEnabled) + Execute.OnUIThread(() => { - Uri burl = new Uri(ButtonSystemUrl); - new ToastContentBuilder() - .AddText(_notificationTitle) - .AddText(_contentCollection.ToString()) - .AddButton(new ToastButton() - .SetContent(_buttonSystemText) - .SetProtocolActivation(burl)) - .Show(); - } - else - { - new ToastContentBuilder() - .AddText(_notificationTitle) - .AddText(_contentCollection.ToString()) - .Show(); - } + if (_buttonSystemEnabled) + { + Uri burl = new Uri(ButtonSystemUrl); + new ToastContentBuilder() + .AddText(_notificationTitle) + .AddText(_contentCollection.ToString()) + .AddButton(new ToastButton() + .SetContent(_buttonSystemText) + .SetProtocolActivation(burl)) + .Show(); + } + else + { + new ToastContentBuilder() + .AddText(_notificationTitle) + .AddText(_contentCollection.ToString()) + .Show(); + } + }); } catch (Exception e) {