Split Scheduler class into two files, one containing only the static time source management code (which I might decide to put somewhere else after all); added an option for users of the scheduler to query the scheduler's time source; fixed typo
git-svn-id: file:///srv/devel/repo-conversion/nusu@191 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
35a4da16fc
commit
2b94c316f6
6 changed files with 103 additions and 47 deletions
|
@ -28,31 +28,11 @@ using Nuclex.Support.Collections;
|
|||
namespace Nuclex.Support.Scheduling {
|
||||
|
||||
/// <summary>Schedules actions for execution at a future point in time</summary>
|
||||
public class Scheduler : ISchedulerService, IDisposable {
|
||||
public partial class Scheduler : ISchedulerService, IDisposable {
|
||||
|
||||
/// <summary>One tick is 100 ns, meaning 10000 ticks equal 1 ms</summary>
|
||||
private const long TicksPerMillisecond = 10000;
|
||||
|
||||
#region class TimeSourceSingleton
|
||||
|
||||
/// <summary>
|
||||
/// Manages the singleton instance of the scheduler's default time source
|
||||
/// </summary>
|
||||
private class TimeSourceSingleton {
|
||||
|
||||
/// <summary>
|
||||
/// Explicit static constructor to guarantee the singleton is initialized only
|
||||
/// when a static member of this class is accessed.
|
||||
/// </summary>
|
||||
static TimeSourceSingleton() { } // Do not remove!
|
||||
|
||||
/// <summary>The singleton instance of the default time source</summary>
|
||||
internal static readonly ITimeSource Instance = Scheduler.CreateDefaultTimeSource();
|
||||
|
||||
}
|
||||
|
||||
#endregion // class TimeSourceSingleton
|
||||
|
||||
#region class Notification
|
||||
|
||||
/// <summary>Scheduled notification</summary>
|
||||
|
@ -187,6 +167,11 @@ namespace Nuclex.Support.Scheduling {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Time source being used by the scheduler</summary>
|
||||
public ITimeSource TimeSource {
|
||||
get { return this.timeSource; }
|
||||
}
|
||||
|
||||
/// <summary>Schedules a notification at the specified absolute time</summary>
|
||||
/// <param name="notificationTime">
|
||||
/// Absolute time at which the notification will occur
|
||||
|
@ -320,30 +305,6 @@ namespace Nuclex.Support.Scheduling {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns the default time source for the scheduler</summary>
|
||||
public static ITimeSource DefaultTimeSource {
|
||||
get { return TimeSourceSingleton.Instance; }
|
||||
}
|
||||
|
||||
/// <summary>Creates a new default time source for the scheduler</summary>
|
||||
/// <param name="useWindowsTimeSource">
|
||||
/// Whether the specialized windows time source should be used
|
||||
/// </param>
|
||||
/// <returns>The newly created time source</returns>
|
||||
internal static ITimeSource CreateTimeSource(bool useWindowsTimeSource) {
|
||||
if(useWindowsTimeSource) {
|
||||
return new WindowsTimeSource();
|
||||
} else {
|
||||
return new GenericTimeSource();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates a new default time source for the scheduler</summary>
|
||||
/// <returns>The newly created time source</returns>
|
||||
internal static ITimeSource CreateDefaultTimeSource() {
|
||||
return CreateTimeSource(WindowsTimeSource.Available);
|
||||
}
|
||||
|
||||
/// <summary>Called when the system date/time have been adjusted</summary>
|
||||
/// <param name="sender">Time source which detected the adjustment</param>
|
||||
/// <param name="arguments">Not used</param>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue