Beispiel #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="dt">时间</param>
 /// <param name="tm">定时模式</param>
 /// <param name="tl">定时条件</param>
 /// <param name="mark">备注</param>
 public TimedRemind(DateTime dt, EnmuTimedMode tm = EnmuTimedMode.Timekeep, EnmuTimeLoop tl = EnmuTimeLoop.One, String mark = "")
 {
     TimeDate  = dt;
     TimedMode = tm;
     TimeLoop  = tl;
     Mark      = mark;
     Status    = EnmuTimedStatus.Ready;
 }
Beispiel #2
0
        /// <summary>
        /// 获取指定时间剩余秒数
        /// </summary>
        /// <param name="dt">指定未来时间</param>
        /// <param name="mode">定时模式</param>
        /// <returns>待延时的秒数</returns>
        private int GetDelayTime(DateTime dt, EnmuTimedMode mode = EnmuTimedMode.Timekeep)
        {
            int delayTime = 0;

            if (mode == EnmuTimedMode.Timekeep)
            {
                delayTime = dt.Second + dt.Minute * 60 + dt.Hour * 3600;
            }
            else if (mode == EnmuTimedMode.Timed)
            {
                DateTime now = DateTime.Now;
                delayTime = Convert.ToInt32(dt.Subtract(now).TotalSeconds);
                if (delayTime < 0)
                {
                    delayTime += 24 * 3600;
                }
            }
            return(delayTime);
        }