public override IScheduledTask Schedule(Action <object> action, object state, TimeSpan delay) { if (action is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } return(Schedule(new StateActionScheduledTask(this, action, state, PreciseTime.DeadlineNanos(delay)))); }
public override IScheduledTask Schedule(IRunnable action, TimeSpan delay) { if (action is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } return(Schedule(new RunnableScheduledTask(this, action, PreciseTime.DeadlineNanos(delay)))); }
public override IScheduledTask ScheduleWithFixedDelay(Action <object> action, object state, TimeSpan initialDelay, TimeSpan delay) { if (action is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } if (delay <= TimeSpan.Zero) { ThrowHelper.ThrowArgumentException_DelayMustBeGreaterThanZero(); } return(Schedule(new StateActionScheduledTask(this, action, state, PreciseTime.DeadlineNanos(initialDelay), -PreciseTime.ToDelayNanos(delay)))); }
public override IScheduledTask ScheduleAtFixedRate(Action action, TimeSpan initialDelay, TimeSpan period) { if (action is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } if (period <= TimeSpan.Zero) { ThrowHelper.ThrowArgumentException_PeriodMustBeGreaterThanZero(); } return(Schedule(new ActionScheduledTask(this, action, PreciseTime.DeadlineNanos(initialDelay), PreciseTime.ToDelayNanos(period)))); }
public override Task ScheduleAsync(Action <object> action, object state, TimeSpan delay, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(TaskUtil.Cancelled); } if (!cancellationToken.CanBeCanceled) { return(Schedule(action, state, delay).Completion); } if (action is null) { return(ThrowHelper.FromArgumentNullException(ExceptionArgument.action)); } return(Schedule(new StateActionScheduledAsyncTask(this, action, state, PreciseTime.DeadlineNanos(delay), cancellationToken)).Completion); }
public override Task ScheduleWithFixedDelayAsync(Action <object> action, object state, TimeSpan initialDelay, TimeSpan delay, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(TaskUtil.Cancelled); } if (!cancellationToken.CanBeCanceled) { return(ScheduleWithFixedDelay(action, state, initialDelay, delay).Completion); } if (action is null) { return(ThrowHelper.FromArgumentNullException(ExceptionArgument.action)); } if (delay <= TimeSpan.Zero) { return(ThrowHelper.FromArgumentException_DelayMustBeGreaterThanZero()); } return(Schedule(new StateActionScheduledAsyncTask(this, action, state, PreciseTime.DeadlineNanos(initialDelay), -PreciseTime.ToDelayNanos(delay), cancellationToken)).Completion); }
public override Task ScheduleAtFixedRateAsync(Action action, TimeSpan initialDelay, TimeSpan period, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(TaskUtil.Cancelled); } if (!cancellationToken.CanBeCanceled) { return(ScheduleAtFixedRate(action, initialDelay, period).Completion); } if (action is null) { return(ThrowHelper.FromArgumentNullException(ExceptionArgument.action)); } if (period <= TimeSpan.Zero) { return(ThrowHelper.FromArgumentException_PeriodMustBeGreaterThanZero()); } return(Schedule(new ActionScheduledAsyncTask(this, action, PreciseTime.DeadlineNanos(initialDelay), PreciseTime.ToDelayNanos(period), cancellationToken)).Completion); }