diff --git a/src/MaaWpfGui/Helper/Notification/NotificationImplWinRT.cs b/src/MaaWpfGui/Helper/Notification/NotificationImplWinRT.cs index b99de15409..e89369a379 100644 --- a/src/MaaWpfGui/Helper/Notification/NotificationImplWinRT.cs +++ b/src/MaaWpfGui/Helper/Notification/NotificationImplWinRT.cs @@ -39,18 +39,25 @@ internal class NotificationImplWinRT : INotificationPoster, IDisposable public void ShowNotification(NotificationContent content) { - Application.Current.Dispatcher.Invoke(() => + try { - var builder = new ToastContentBuilder().AddText(content.Body).AddText(content.Summary); - - foreach (var action in content.Actions) + Application.Current.Dispatcher.Invoke(() => { - builder.AddButton(new ToastButton() - .SetContent(action.Label) - .AddArgument(action.Tag)); - } + var builder = new ToastContentBuilder().AddText(content.Body).AddText(content.Summary); - builder.Show(); - }); + foreach (var action in content.Actions) + { + builder.AddButton(new ToastButton() + .SetContent(action.Label) + .AddArgument(action.Tag)); + } + + builder.Show(); + }); + } + catch + { + // ignored + } } } diff --git a/src/MaaWpfGui/Helper/Notification/NotificationImplWpf.cs b/src/MaaWpfGui/Helper/Notification/NotificationImplWpf.cs index 56535ec200..49d76bdd6b 100644 --- a/src/MaaWpfGui/Helper/Notification/NotificationImplWpf.cs +++ b/src/MaaWpfGui/Helper/Notification/NotificationImplWpf.cs @@ -143,9 +143,16 @@ internal class NotificationImplWpf : INotificationPoster wpfcontent.RightButtonAction = () => ActionActivated?.Invoke(this, action.Tag); } - Application.Current.Dispatcher.Invoke(() => + try { - _notificationManager.Show(wpfcontent, expirationTime: expirationTime, ShowXbtn: false); - }); + Application.Current.Dispatcher.Invoke(() => + { + _notificationManager.Show(wpfcontent, expirationTime: expirationTime, ShowXbtn: false); + }); + } + catch + { + // ignored + } } }