C# 删除ToastNotificationManager中的所有通知
我有这个密码C# 删除ToastNotificationManager中的所有通知,c#,windows-phone-8.1,windows-8.1,windows-10,toast,C#,Windows Phone 8.1,Windows 8.1,Windows 10,Toast,我有这个密码 public void RemoveExistingToastNotifications() { var TNM = ToastNotificationManager.CreateToastNotifier(); var notifications = TNM.GetScheduledToastNotifications(); for (int i = 0; i < notifications.Count; i
public void RemoveExistingToastNotifications()
{
var TNM = ToastNotificationManager.CreateToastNotifier();
var notifications = TNM.GetScheduledToastNotifications();
for (int i = 0; i < notifications.Count; i++)
{
TNM.RemoveFromSchedule(notifications[i]);
}
}
它工作得很好,但值得注意的是,这种方法的性能不是很好。对于Windows系统8.1及更高版本,有没有更好更快的方法来删除所有通知?没有其他API可以一次删除所有通知。我建议您提交一个请求来请求这个新功能。使用xperf/WPA来跟踪哪个代码部分比较慢:,我按照您的建议做了。