コード例 #1
0
        public void Run(GimmickValue value, DateTime current)
        {
            if (lastTriggerReceivedAt == value.TimeStamp)
            {
                return;
            }
            lastTriggerReceivedAt = value.TimeStamp;

            var dueTime = value.TimeStamp.AddSeconds(delayTimeSeconds) - current;

            if (dueTime.TotalSeconds < -Constants.Gimmick.TriggerExpireSeconds)
            {
                return;
            }
            var expireAt = Time.realtimeSinceStartup + dueTime.TotalSeconds + Constants.Trigger.OwnershipExpireExpectedSeconds;

            void Action()
            {
                if (expireAt < Time.realtimeSinceStartup)
                {
                    return;
                }
                Invoke();
            }

            schedulerCancellation?.Dispose();
            schedulerCancellation = new Scheduler.Cancellation();
            Scheduler.Schedule(dueTime, Action, schedulerCancellation);
        }
コード例 #2
0
        public void Run(GimmickValue value, DateTime current)
        {
            if (lastTriggerReceivedAt == value.TimeStamp)
            {
                return;
            }
            lastTriggerReceivedAt = value.TimeStamp;

            var dueTime = value.TimeStamp.AddSeconds(delayTimeSeconds) - current;

            if (dueTime.TotalSeconds < -Constants.Gimmick.TriggerExpireSeconds)
            {
                return;
            }

            schedulerCancellation?.Dispose();
            schedulerCancellation = new Scheduler.Cancellation();
            Scheduler.Schedule(dueTime, Invoke, schedulerCancellation);
        }