Ejemplo n.º 1
0
        /// <summary>
        /// 二维秒级定时任务节点
        /// </summary>
        /// <param name="taskArray">二维定时任务数组</param>
        /// <param name="timeoutSeconds">第一次执行任务间隔的秒数</param>
        /// <param name="threadMode">执行任务的线程模式</param>
        /// <param name="KeepMode">定时任务继续模式</param>
        /// <param name="keepSeconds">继续执行间隔秒数,0 表示不继续执行</param>
        internal SecondTimerTaskNode(SecondTimerTaskArray taskArray, int timeoutSeconds, SecondTimerThreadMode threadMode, SecondTimerKeepMode KeepMode, int keepSeconds)
        {
            switch (KeepMode)
            {
            case SecondTimerKeepMode.After:
            case SecondTimerKeepMode.Before:
                if (keepSeconds <= 0)
                {
                    KeepMode = SecondTimerKeepMode.Once;
                }
                else
                {
                    this.keepSeconds = keepSeconds;
                    if (timeoutSeconds < 0)
                    {
                        timeoutSeconds = 0;
                    }
                }
                break;
            }

            this.taskArray  = taskArray;
            TimeoutSeconds  = SecondTimer.CurrentSeconds + timeoutSeconds;
            this.threadMode = threadMode;
            this.KeepMode   = KeepMode;
        }
Ejemplo n.º 2
0
        static SecondTimer()
        {
            byte taskArrayBitSize = AutoCSer.Common.Config.TimeoutCapacityBitSize;

            InternalTaskArray = new SecondTimerTaskArray(taskArrayBitSize);
            TaskArray         = new SecondTimerTaskArray(taskArrayBitSize);

            UtcNow          = (Now = DateTime.Now).localToUniversalTime();
            NextSecondTicks = ((Now.Ticks / TimeSpan.TicksPerSecond) + 1) * TimeSpan.TicksPerSecond;
            timer           = new Timer(refreshTime, null, TimerInterval = 1000L - Now.Millisecond, -1);
        }
Ejemplo n.º 3
0
        internal SecondTimerActionTask(SecondTimerTaskArray taskArray, Action task, int timeoutSeconds, SecondTimerThreadMode threadMode = SecondTimerThreadMode.TaskRun, SecondTimerKeepMode KeepMode = SecondTimerKeepMode.Once, int keepSeconds = 0)
#endif
            : base(taskArray, timeoutSeconds, threadMode, KeepMode, keepSeconds)
        {
            this.task = task;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 二维秒级定时委托任务节点
        /// </summary>
        /// <param name="taskArray">二维定时任务数组</param>
        /// <param name="task">委托任务</param>
        /// <param name="timeoutSeconds">第一次执行任务间隔的秒数</param>
        /// <param name="threadMode">执行任务的线程模式</param>
        /// <param name="KeepMode">定时任务继续模式</param>
        /// <param name="keepSeconds">继续执行间隔秒数,0 表示不继续执行</param>
#if DOTNET2 || DOTNET4 || UNITY3D
        internal SecondTimerActionTask(SecondTimerTaskArray taskArray, Action task, int timeoutSeconds, SecondTimerThreadMode threadMode = SecondTimerThreadMode.TinyBackgroundThreadPool, SecondTimerKeepMode KeepMode = SecondTimerKeepMode.Once, int keepSeconds = 0)