Esempio n. 1
0
        public Task WaitAsync(long time)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            Timer timer = new Timer {
                Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs
            };

            this.timers[timer.Id] = timer;
            this.timeId.Add(timer.Time, timer.Id);
            if (timer.Time < this.minTime)
            {
                this.minTime = timer.Time;
            }
            return(tcs.Task);
        }
Esempio n. 2
0
        public Task WaitTillAsync(long tillTime, CancellationToken cancellationToken)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            Timer timer = new Timer {
                Id = IdGenerater.GenerateId(), Time = tillTime, tcs = tcs
            };

            this.timers[timer.Id] = timer;
            this.timeId.Add(timer.Time, timer.Id);
            if (timer.Time < this.minTime)
            {
                this.minTime = timer.Time;
            }
            cancellationToken.Register(() => { this.Remove(timer.Id); });
            return(tcs.Task);
        }
Esempio n. 3
0
 protected Object()
 {
     this.id = IdGenerater.GenerateId();
 }