Skip to content

Scheduler.Sleep(IScheduler, TimeSpan) method

Defined in

Type: Scheduler Namespace: System.Reactive.Concurrency Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime)
  • 2. public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime, CancellationToken cancellationToken)
  • 3. public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime)
  • 4. public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime, CancellationToken cancellationToken)

1. Overload

public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime)

Summary: Suspends execution of the current work item on the scheduler for the specified duration. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) after the specified duration.

Parameters

NameTypeDescription
scheduler[IScheduler](#Scheduler to yield work on.
dueTimeTimeSpanTime when the continuation should run.

Returns: SchedulerOperation -- Scheduler operation object to await in order to schedule the continuation.

Exceptions

TypeCondition
System.ArgumentNullExceptionscheduler is null.

2. Overload

public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime, CancellationToken cancellationToken)

Summary: Suspends execution of the current work item on the scheduler for the specified duration. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) after the specified duration.

Parameters

NameTypeDescription
scheduler[IScheduler](#Scheduler to yield work on.
dueTimeTimeSpanTime when the continuation should run.
cancellationTokenCancellationTokenCancellation token to cancel the continuation to run.

Returns: SchedulerOperation -- Scheduler operation object to await in order to schedule the continuation.

Exceptions

TypeCondition
System.ArgumentNullExceptionscheduler is null.

3. Overload

public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime)

Summary: Suspends execution of the current work item on the scheduler until the specified due time. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) at the specified due time.

Parameters

NameTypeDescription
scheduler[IScheduler](#Scheduler to yield work on.
dueTimeDateTimeOffsetTime when the continuation should run.

Returns: SchedulerOperation -- Scheduler operation object to await in order to schedule the continuation.

Exceptions

TypeCondition
System.ArgumentNullExceptionscheduler is null.

4. Overload

public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime, CancellationToken cancellationToken)

Summary: Suspends execution of the current work item on the scheduler until the specified due time. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) at the specified due time.

Parameters

NameTypeDescription
scheduler[IScheduler](#Scheduler to yield work on.
dueTimeDateTimeOffsetTime when the continuation should run.
cancellationTokenCancellationTokenCancellation token to cancel the continuation to run.

Returns: SchedulerOperation -- Scheduler operation object to await in order to schedule the continuation.

Exceptions

TypeCondition
System.ArgumentNullExceptionscheduler is null.