/// <summary> /// 初始化本线程的Scheduler /// </summary> /// <param name="numSlots">总槽数,越大则槽冲突越小</param> /// <param name="slotInterval">槽间隔,越小精度越高,单位毫秒</param> /// /// <param name="dateTimeProvider">获取当前DateTime的函数</param> internal static void Initialize(int numSlots, int slotInterval, Func <DateTime> dateTimeProvider) { if (currentScheduler != null) { throw new InvalidOperationException("SlotTimerScheduler has been initialized in this thread."); } currentScheduler = new TimerScheduler(numSlots, slotInterval, dateTimeProvider); }
public static void InitializeScheduler(int numSlots, int slotInterval, Func <DateTime> dateTimeProvider) { TimerScheduler.Initialize(numSlots, slotInterval, dateTimeProvider); }
public Timer() { scheduler = TimerScheduler.CurrentScheduler; }