Moved the checkForTimeAdjustment() method in the generic time source behind the WaitOne() call because that's the most likely point for a date/time adjustment will have occurred at; WindowsTimeSource now exists on the XBox 360 as well, but will throw in its constructor and report Available as false (this simplifies things in other places); Scheduler class is fully working and 100% testable with simulated time (instead of waiting for scheduled notifications to be delivered in real time, which would make testing slow); added unit tests for Scheduler class and reached 100% coverage

git-svn-id: file:///srv/devel/repo-conversion/nusu@145 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-06-09 19:28:11 +00:00
parent 4b9002b520
commit a6f7749121
4 changed files with 525 additions and 43 deletions

View file

@ -87,12 +87,18 @@ namespace Nuclex.Support.Scheduling {
/// True if the WaitHandle was signalled, false if the timeout was reached
/// </returns>
public virtual bool WaitOne(AutoResetEvent waitHandle, long ticks) {
checkForTimeAdjustment();
// Force a timeout at least each second so the caller can check the system time
// since we're not able to provide the DateTimeAdjusted notification
int milliseconds = (int)(ticks / TicksPerMillisecond);
return waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
// See whether the system date/time have been adjusted while we were asleep.
checkForTimeAdjustment();
// Now tell the caller whether his even was signalled
return signalled;
}
/// <summary>Current system time in UTC format</summary>