private void DisplayNotification(object sender, EventArgs e) { bool isWindowOpen = false; foreach (Window w in Application.Current.Windows) { if (w is NotificationWindow || w is NotificationPreviewWindow) { isWindowOpen = true; } } if (!isWindowOpen) { if (NotificationQueue.Count != 0) { Notification n = NotificationQueue.First(); NotificationQueue.Remove(n); NotificationWindow newWindow = new NotificationWindow(); (newWindow.DataContext as NotificationWindowViewModel).Notification = n.NotificationString; newWindow.Show(); } } }
public override void Update() { base.Update(); /* If queue is empty take easy way out */ if (NotificationQueue.Count == 0) { return; } /* Only Check Every X Updates and not every. */ updateCount++; if (updateCount < SKIPPED_UPDATES) { return; } updateCount = 0; try { foreach (EntityIdCooldownKey cooldownKey in NotificationQueue.ToList()) { if (CooldownManagerNotificationQueue.CheckCooldown(cooldownKey, NOTIFICATION_COOLDOWN_COMMAND, out _)) { long identityId = cooldownKey.EntityId; NotifyPlayer(identityId); NotificationQueue.Remove(cooldownKey); } } } catch (Exception e) { Log.Error(e, "Error on Update!"); } }