Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
 public static void InitializeScheduler(int numSlots, int slotInterval, Func <DateTime> dateTimeProvider)
 {
     TimerScheduler.Initialize(numSlots, slotInterval, dateTimeProvider);
 }
Beispiel #3
0
 public Timer()
 {
     scheduler = TimerScheduler.CurrentScheduler;
 }