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
| Name | Type | Description |
|---|---|---|
period | TimeSpan | Period 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
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
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | period 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
| Name | Type | Description |
|---|---|---|
period | TimeSpan | Period 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
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
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | period is less than TimeSpan.Zero. |
| System.ArgumentNullException | scheduler is null. |