示例#1
0
        protected AsyncStep CallAsyncSleep(TimeSpan amountToSleep)
        {
            Debug.Assert(amountToSleep != TimeSpan.MaxValue, "IteratorAsyncResult cannot delay for TimeSpan.MaxValue!");

            return(this.CallAsync(
                       (thisPtr, t, c, s) => new SleepAsyncResult(amountToSleep, c, s),
                       (thisPtr, r) => SleepAsyncResult.End(r),
                       (thisPtr, t) => Thread.Sleep(amountToSleep),
                       ExceptionPolicy.Transfer));
        }
示例#2
0
        protected AsyncStep CallAsyncSleep(TimeSpan amountToSleep, CancellationToken cancellationToken)
        {
            Fx.Assert(amountToSleep != TimeSpan.MaxValue, "IteratorAsyncResult cannot delay for TimeSpan.MaxValue!");

            return(this.CallAsync(
                       (thisPtr, t, c, s) => new SleepAsyncResult(amountToSleep, cancellationToken, c, s),
                       (thisPtr, r) => SleepAsyncResult.End(r),
                       (thisPtr, t) => Task.Delay(amountToSleep).Wait(),
                       ExceptionPolicy.Transfer));
        }