From f8adca9e17c54eeebd4c9993fa90ec9d86c5ac37 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Mon, 22 Jun 2009 18:14:45 +0000 Subject: [PATCH] Fixed a glaring bug in the Scheduler causing errors when the scheduler's last item in the queue is cancelled git-svn-id: file:///srv/devel/repo-conversion/nusu@152 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/Scheduling/Scheduler.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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