Exemple #1
0
        /// <summary>
        /// 外部设置延迟多少秒时间的任务 方法由外部指定
        /// </summary>
        /// <param name="id"></param>
        /// <param name="delaytime"></param>
        public void AddTimerEvent(long delaytime, TimerDG td)
        {
            long       time       = DateTime.Now.Ticks + delaytime;
            TimerModle timerModle = new TimerModle(concurrentID.Add_Get(), time, td);

            idTimerDic.TryAdd(timerModle.ID, timerModle);
        }
Exemple #2
0
        /// <summary>
        /// 设置定时触发的任务
        /// </summary>
        /// <param name="dateTime"></param>
        /// <param name="td"></param>
        public void AddTimerEvent(DateTime dateTime, TimerDG td)
        {
            long delaytime = dateTime.Ticks - DateTime.Now.Ticks;

            if (delaytime < 0)
            {
                return;
                //如果延迟时间小于0 证明定时日期在过去
            }
            TimerModle timerModle = new TimerModle(concurrentID.Add_Get(), delaytime, td);

            idTimerDic.TryAdd(timerModle.ID, timerModle);
        }
Exemple #3
0
 public TimerModle(int id, long time, TimerDG td)
 {
     ID          = id;
     Time        = time;
     TimerEvent += td;
 }