,System.TimeSpan)} ,System.TimeSpan,System.Reactive.Concurrency.IScheduler)} ,System.DateTimeOffset)} ,System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)} ,System.Func{--0,System.IObservable{--1}})} ,System.IObservable{--1},System.Func{--0,System.IObservable{--1}})}
Observable.Delay(IObservable, TimeSpan) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, TimeSpan dueTime) - 2.
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler) - 3.
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime) - 4.
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler) - 5.
public static IObservable<TSource> Delay<TSource, TDelay>(this IObservable<TSource> source, Func<TSource, IObservable<TDelay>> delayDurationSelector) - 6.
public static IObservable<TSource> Delay<TSource, TDelay>(this IObservable<TSource> source, IObservable<TDelay> subscriptionDelay, Func<TSource, IObservable<TDelay>> delayDurationSelector)
1. Overload¶
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, TimeSpan dueTime)
Summary: Time shifts the observable sequence by the specified relative time duration. The relative time intervals between the values are preserved.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
dueTime | TimeSpan | Relative time by which to shift the observable sequence. If this value is equal to TimeSpan.Zero, the scheduler will dispatch observer callbacks as soon as possible. |
Returns: IObservable
Remarks
This operator is less efficient than DelaySubscription because it records all notifications and time-delays those. This allows for immediate propagation of errors.
Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped. In order to delay error propagation, consider using the Materialize and Dematerialize operators, or use DelaySubscription.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
2. Overload¶
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
Summary: Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers. The relative time intervals between the values are preserved.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
dueTime | TimeSpan | Relative time by which to shift the observable sequence. If this value is equal to TimeSpan.Zero, the scheduler will dispatch observer callbacks as soon as possible. |
scheduler | [IScheduler](# | Scheduler to run the delay timers on. |
Returns: IObservable
Remarks
This operator is less efficient than DelaySubscription because it records all notifications and time-delays those. This allows for immediate propagation of errors.
Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped. In order to delay error propagation, consider using the Materialize and Dematerialize operators, or use DelaySubscription.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
| System.ArgumentOutOfRangeException | dueTime is less than TimeSpan.Zero. |
3. Overload¶
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime)
Summary: Time shifts the observable sequence to start propagating notifications at the specified absolute time. The relative time intervals between the values are preserved.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
dueTime | DateTimeOffset | Absolute time used to shift the observable sequence; the relative time shift gets computed upon subscription. If this value is less than or equal to DateTimeOffset.UtcNow, the scheduler will dispatch observer callbacks as soon as possible. |
Returns: IObservable
Remarks
This operator is less efficient than DelaySubscription because it records all notifications and time-delays those. This allows for immediate propagation of errors.
Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped. In order to delay error propagation, consider using the Materialize and Dematerialize operators, or use DelaySubscription.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
4. Overload¶
public static IObservable<TSource> Delay<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
Summary: Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers. The relative time intervals between the values are preserved.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
dueTime | DateTimeOffset | Absolute time used to shift the observable sequence; the relative time shift gets computed upon subscription. If this value is less than or equal to DateTimeOffset.UtcNow, the scheduler will dispatch observer callbacks as soon as possible. |
scheduler | [IScheduler](# | Scheduler to run the delay timers on. |
Returns: IObservable
Remarks
This operator is less efficient than DelaySubscription because it records all notifications and time-delays those. This allows for immediate propagation of errors.
Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped. In order to delay error propagation, consider using the Materialize and Dematerialize operators, or use DelaySubscription.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
5. Overload¶
public static IObservable<TSource> Delay<TSource, TDelay>(this IObservable<TSource> source, Func<TSource, IObservable<TDelay>> delayDurationSelector)
Summary: Time shifts the observable sequence based on a delay selector function for each element.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TDelay | The type of the elements in the delay sequences used to denote the delay duration of each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
delayDurationSelector | Func | Selector function to retrieve a sequence indicating the delay for each given element. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or delayDurationSelector is null. |
6. Overload¶
public static IObservable<TSource> Delay<TSource, TDelay>(this IObservable<TSource> source, IObservable<TDelay> subscriptionDelay, Func<TSource, IObservable<TDelay>> delayDurationSelector)
Summary: Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TDelay | The type of the elements in the delay sequences used to denote the delay duration of each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence to delay values for. |
subscriptionDelay | IObservable | Sequence indicating the delay for the subscription to the source. |
delayDurationSelector | Func | Selector function to retrieve a sequence indicating the delay for each given element. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or subscriptionDelay or delayDurationSelector is null. |