fix: 暂时忽略吐司通知报错

This commit is contained in:
uye
2024-05-26 03:05:27 +08:00
parent 3622caecf2
commit 222bb7f3a7
2 changed files with 27 additions and 13 deletions

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}