Ejemplo n.º 1
0
        private void Run(TimerAction timerAction)
        {
            switch (timerAction.TimerClass)
            {
            case TimerClass.OnceTimer:
            {
                ETTask <bool> tcs = timerAction.Object as ETTask <bool>;
                this.Remove(timerAction.Id);
                tcs.SetResult(true);
                break;
            }

            case TimerClass.RepeatedTimer:
            {
                int  type     = timerAction.Type;
                long tillTime = TimeHelper.ServerNow() + timerAction.Time;
                this.AddTimer(tillTime, timerAction);

                ITimer timer = this.timerActions[type];
                if (timer == null)
                {
                    Log.Error($"not found timer action: {type}");
                    return;
                }
                timer.Handle(timerAction.Object);
                break;
            }
            }
        }