public void Hide(Guid id) { var n = NotificationMessages.SingleOrDefault(x => x.Id == id); if (n?.InvokeHideAnimation == null) { return; } n.InvokeHideAnimation(); Task.Factory.StartNew(() => { Thread.Sleep(200); }).ContinueWith(t => { NotificationMessages.Remove(n); if (NotificationMessages.Any() == false) { InternalStopTimer(); IsOpen = false; } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void Hide(Guid id) { var n = NotificationMessages.SingleOrDefault(x => x.Id == id); if (n?.InvokeHideAnimation == null) { return; } n.InvokeHideAnimation(); var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200), Tag = n }; timer.Tick += RemoveNotificationsTimer_OnTick; timer.Start(); }