Table of Contents

Class DelayOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Implements the Delay operator. Mirrors rxjs's delay.

public static class DelayOperator
Inheritance
System.Object
DelayOperator

Methods

Delay<T>(Observable<T>, TimeSpan, IScheduler?)

Time-shifts every value from source by due, preserving relative order.

public static Observable<T> Delay<T>(this Observable<T> source, TimeSpan due, IScheduler? scheduler = null)

Parameters

source Observable<T>

The source observable to delay.

due TimeSpan

The amount of time by which to shift each value (see remarks for burst behavior).

scheduler IScheduler

The scheduler used to run the delay timer. Defaults to Instance when null.

Returns

Observable<T>

An observable that emits the same values as source, each shifted later in time by roughly due, followed by the same completion or (immediate) error notification.

Type Parameters

T

The type of the values being delayed.

Remarks

Deliberately NOT built on DelayWhen/MergeMap: those subscribe to one independent timer per value concurrently, and real timers (backed by the thread pool) don't guarantee same-duration timers fire back in the order they were scheduled — which silently breaks the ordering guarantee this operator's own documentation (and rxjs's) promises. Instead, this serializes emission through a single queue: only one timer is ever active, always for the queue head, so firing order always matches arrival order regardless of scheduler jitter.

Known simplification: for a burst of synchronous values, each one's delay is measured from when its predecessor fired rather than from its own arrival, so latencies stack (item N fires at roughly N × due) instead of each value landing at a uniform offset from when it arrived. Correct for the common "space out slower-than-due emissions" case; revisit if a real use case needs precise per-item latency under bursts (that's what the full scheduler/timer-queue work in M4 is for).

Errors are not queued: an error from source is forwarded immediately, without waiting for any already-queued values to be flushed.