Fixed a nasty bug that would make the scheduler queue notifications using their delay time as absolute notification time, causing negative numbers to be passed to WaitOne(); updated unit test to expose this problem if it happens

git-svn-id: file:///srv/devel/repo-conversion/nusu@146 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-06-09 19:41:38 +00:00
parent a6f7749121
commit 6b8362d57d
2 changed files with 7 additions and 6 deletions

View File

@ -47,6 +47,7 @@ namespace Nuclex.Support.Scheduling {
/// <param name="utcStartTime">Start time in UTC format</param>
public MockTimeSource(DateTime utcStartTime) {
this.currentTime = utcStartTime;
this.currentTicks = 1000000000;
}
/// <summary>Waits for an AutoResetEvent to become signalled</summary>

View File

@ -128,10 +128,10 @@ namespace Nuclex.Support.Scheduling {
}
}
#endregion // class NotificationComparer
}
#endregion // class NotificationComparer
/// <summary>Initializes a new scheduler using the default time source</summary>
public Scheduler() : this(DefaultTimeSource) { }
@ -235,7 +235,7 @@ namespace Nuclex.Support.Scheduling {
return scheduleNotification(
new Notification(
0,
delay.Ticks,
this.timeSource.Ticks + delay.Ticks,
DateTime.MinValue,
callback
)
@ -256,7 +256,7 @@ namespace Nuclex.Support.Scheduling {
return scheduleNotification(
new Notification(
0,
(long)delayMilliseconds * TicksPerMillisecond,
this.timeSource.Ticks + ((long)delayMilliseconds * TicksPerMillisecond),
DateTime.MinValue,
callback
)
@ -276,7 +276,7 @@ namespace Nuclex.Support.Scheduling {
return scheduleNotification(
new Notification(
interval.Ticks,
delay.Ticks,
this.timeSource.Ticks + delay.Ticks,
DateTime.MinValue,
callback
)
@ -302,7 +302,7 @@ namespace Nuclex.Support.Scheduling {
return scheduleNotification(
new Notification(
(long)intervalMilliseconds * TicksPerMillisecond,
(long)delayMilliseconds * TicksPerMillisecond,
this.timeSource.Ticks + ((long)delayMilliseconds * TicksPerMillisecond),
DateTime.MinValue,
callback
)