private void RemoveNotificationsTimer_OnTick(object sender, EventArgs eventArgs) { var timer = sender as DispatcherTimer; if (timer == null) { return; } // Stop the timer and cleanup for GC timer.Tick += RemoveNotificationsTimer_OnTick; timer.Stop(); var n = timer.Tag as NotificationViewModel; if (n == null) { return; } NotificationMessages.Remove(n); if (NotificationMessages.Any()) { return; } InternalStopTimer(); IsOpen = false; }
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()); }