diff --git a/Source/Scheduling/Scheduler.cs b/Source/Scheduling/Scheduler.cs index 781c8e3..f0a5f26 100644 --- a/Source/Scheduling/Scheduler.cs +++ b/Source/Scheduling/Scheduler.cs @@ -465,17 +465,16 @@ namespace Nuclex.Support.Scheduling { /// Retrieves the notification that is due next /// The notification that is due next private Notification getNextDueNotification() { - if(this.notifications.Count == 0) { - return null; - } else { + while(this.notifications.Count > 0) { Notification nextDueNotification = this.notifications.Peek(); - while(nextDueNotification.Cancelled) { + if(nextDueNotification.Cancelled) { this.notifications.Dequeue(); - nextDueNotification = this.notifications.Peek(); + } else { + return nextDueNotification; } - - return nextDueNotification; } + + return null; } /// Time source used by the scheduler