/// <summary>
 /// 定时器周期时间读取器
 /// </summary>
 /// <param name="timerPeriodic">定时器周期数据</param>
 public TimerPeriodicReader(ref TimerPeriodic timerPeriodic)
 {
     this.timerPeriodic = timerPeriodic;
     intervalTicks      = timerPeriodic.GetIntervalTicks();
     time = default(DateTime);
 }
Beispiel #2
0
 /// <summary>
 /// 周期定时任务
 /// </summary>
 /// <param name="run">定时任务</param>
 /// <param name="timerPeriodic">定时器周期数据</param>
 /// <param name="threadMode">定时任务线程模式</param>
 /// <param name="isSkipTime">下一次执行是否跳过当前时间,比如电脑休眠以后会产生时间差</param>
 public TimerPeriodicTask(Action run, TimerPeriodic timerPeriodic, SecondTimerThreadMode threadMode = SecondTimerThreadMode.TinyBackgroundThreadPool, bool isSkipTime = true)
 {
     if (run == null)
     {
         throw new ArgumentNullException();
     }
     this.run           = run;
     this.timerPeriodic = timerPeriodic;
     this.threadMode    = threadMode;
     this.isSkipTime    = isSkipTime;
     SecondTimer.TaskArray.Append(runHandle = Run, runTime = timerPeriodic.GetStartRunTime(intervalTicks = timerPeriodic.GetIntervalTicks()), threadMode);
 }
 /// <summary>
 /// 周期定时任务
 /// </summary>
 /// <param name="run">定时任务</param>
 /// <param name="timerPeriodic">定时器周期数据</param>
 /// <param name="threadType">定时任务线程模式</param>
 public TimerPeriodicTask(Action run, TimerPeriodic timerPeriodic, TimerTaskThreadType threadType = TimerTaskThreadType.ThreadPool)
 {
     if (run == null)
     {
         throw new ArgumentNullException();
     }
     this.run        = run;
     this.threadType = threadType;
     TimerTask.Default.Add(runHandle = Run, runTime = timerPeriodic.GetStartRunTime(intervalTicks = timerPeriodic.GetIntervalTicks()), threadType);
 }