コード例 #1
0
 private Task InternalScheduleRepeatedly(int initialDelayMs, int intervalMs, Func <bool> action, CancellationToken token)
 {
     if (initialDelayMs == Timeout.Infinite)
     {
         return(TaskExt.CreateInfiniteTask());
     }
     return(InternalScheduleRepeatedlyAsync(initialDelayMs, intervalMs, action, token));
 }
コード例 #2
0
        private Task InternalScheduleOnce(int initialDelayMs, Action action, CancellationToken token)
        {
            if (initialDelayMs == Timeout.Infinite)
            {
                return(TaskExt.CreateInfiniteTask());
            }
            if (initialDelayMs <= 0)
            {
                action();
                return(TaskExt.CreateCompletedTask());
            }

            return(Task.Delay(initialDelayMs, token).Then(t => action()));
        }