public async ETTask <bool> WaitAsync(long time, ETCancellationToken cancellationToken = null) { if (time == 0) { return(true); } long tillTime = TimeHelper.ServerNow() + time; ETTask <bool> tcs = ETTask <bool> .Create(true); TimerAction timer = this.AddChild <TimerAction, TimerClass, long, int, object>(TimerClass.OnceWaitTimer, time, 0, tcs, true); this.AddTimer(tillTime, timer); long timerId = timer.Id; void CancelAction() { if (this.Remove(timerId)) { tcs.SetResult(false); } } bool ret; try { cancellationToken?.Add(CancelAction); ret = await tcs; } finally { cancellationToken?.Remove(CancelAction); } return(ret); }