Skip to content

Observable.Interval(TimeSpan) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<long> Interval(TimeSpan period)
  • 2. public static IObservable<long> Interval(TimeSpan period, IScheduler scheduler)

1. Overload

public static IObservable<long> Interval(TimeSpan period)

Summary: Returns an observable sequence that produces a value after each period.

Parameters

NameTypeDescription
periodTimeSpanPeriod for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.

Returns: IObservable -- An observable sequence that produces a value after each period.

Remarks

Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification. If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the Generate operator instead.

Exceptions

TypeCondition
System.ArgumentOutOfRangeExceptionperiod is less than TimeSpan.Zero.

2. Overload

public static IObservable<long> Interval(TimeSpan period, IScheduler scheduler)

Summary: Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.

Parameters

NameTypeDescription
periodTimeSpanPeriod for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.
scheduler[IScheduler](#Scheduler to run the timer on.

Returns: IObservable -- An observable sequence that produces a value after each period.

Remarks

Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification. If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the Generate operator instead.

Exceptions

TypeCondition
System.ArgumentOutOfRangeExceptionperiod is less than TimeSpan.Zero.
System.ArgumentNullExceptionscheduler is null.