Exemple #1
0
        public void ChangeTimer(IVersionedTimer timer, TimeSpan timeout, TimeSpan period, long version)
        {
            // Save the elapsed as soon as possible, to keep the accounting accurate.
            TimeSpan elapsed = this.timeBase.Elapsed;

            if (timeout < TimeSpan.Zero)
            {
                throw new ArgumentException("Timeout must be non-negative.");
            }

            // First, update the timer's properties.
            timer.Period  = period;
            timer.Version = version;

            // We're going to schedule the timer. Calculate its next timeout, make sure it's
            // in the list, and then make sure our prime timer is scheduled before the new timer.

            timer.NextTimeout = elapsed + timeout;

            if (this.timerList.Contains(timer) == false)
            {
                this.timerList.Add(timer);
            }

            EnsurePrimerTimerDueBy(timer.NextTimeout);
        }
Exemple #2
0
 public void DeleteTimer(IVersionedTimer timer)
 {
     this.timerList.Remove(timer);
 }
Exemple #3
0
 public DueTimer(IVersionedTimer timer)
 {
     this.Timer   = timer;
     this.Version = timer.Version;
 }