Example #1
0
        /// <summary>
        /// 执行时间回调函数;
        /// </summary>
        protected static void runTodayTimerHandle(int index = 0)
        {
            int count = todayHandlers.count;

            if (index >= count)
            {
                return;
            }

            TodayTimerHandler value = todayHandlers.getElementByIndex(index);

            System.DateTime now = System.DateTime.Now;
            if (value.isTodayExe == false)
            {
                int hour   = (int)value.hour;
                int minute = (int)(60 * (value.hour - hour));
                if (now.Hour == hour && now.Minute >= minute)
                {
                    runTodayTimerMethod(value);
                    value.isTodayExe = true;
                }
            }
            if (value.lastTime.Day != System.DateTime.Now.Day)
            {
                value.isTodayExe = false;
            }
            value.lastTime = System.DateTime.Now;

            index++;
            runTodayTimerHandle(index);
        }
Example #2
0
        /// <summary>
        /// 今天指定时间做调用,hour(18:30填18.5),method(调用的函数),args(函数参数)
        /// </summary>
        /// <param name="hour"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        public static void RegTodayTimerEvent(float hour, TimerMethod method, object args = null)
        {
            if (method == null)
            {
                return;
            }
            if (todayHandlers.hash.ContainsKey(method))
            {
                return;
            }

            TodayTimerHandler handler = new TodayTimerHandler();
            TimerEvent        events  = new TimerEvent(args);

            events.key     = method;
            handler.method = method;
            handler.args   = events;
            handler.hour   = hour;
            System.DateTime now     = System.DateTime.Now;
            int             phour   = (int)hour;
            int             pminute = (int)(60 * (hour - phour));

            if (now.Hour >= phour && now.Minute >= pminute)
            {
                handler.isTodayExe = true;
            }
            else
            {
                handler.isTodayExe = false;
            }
            handler.lastTime = System.DateTime.Now;
            todayHandlers.addElement(method, handler);
        }
Example #3
0
        /// <summary>
        /// 执行计时器回调函数;
        /// </summary>
        /// <param name="value"></param>
        protected static void runTodayTimerMethod(TodayTimerHandler value)
        {
            TimerMethod method = value.method;

            if (method != null)
            {
                method(value.args);
            }
        }