Table of Contents

Class ObserveOn

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that sends all notifications in the sequence through the specified scheduler.

An observable sequence, and the chain of operators that are applied to it, will usually do its work and notify any downstream observers on the same thread that is used to run the source. The ObserveOn operator can be used to instruct a sequence to send notifications to its observers on a particular scheduler.

Marble diagram

ObserveOn will change the thread used to send notifications only for items emitted downstream from where the operator is introduced. Even if new tasks or threads are created to run notifications, the resulting sequence will keep the order of all emitted items.

Warning

Care must be taken to prevent unbounded accumulation of notifications when consumers following ObserveOn are slower than the rate at which the source produces new items. Reactive operators such as Gate or Slice may be used to manage any backpressure issues.

Marble diagram

Note that ObserveOn will forward any error notification from the source sequence immediately, without waiting for slow-consuming observers to receive previously emitted items. In other words, the error notification may jump ahead of items emitted earlier by the source sequence as in the diagram above.

public class ObserveOn : Combinator
Inheritance
ObserveOn
Inherited Members

Properties

Scheduler

Gets or sets a value specifying the scheduler on which to emit notifications.

[TypeConverter(typeof(SchedulerMappingConverter))]
public SchedulerMapping Scheduler { get; set; }

Property Value

SchedulerMapping

SchedulerSpecified

Gets a value indicating whether the Scheduler property should be serialized.

[Browsable(false)]
public bool SchedulerSpecified { get; }

Property Value

bool

Methods

Process<TSource>(IObservable<TSource>)

Sends all notifications in an observable sequence through the specified scheduler.

public override IObservable<TSource> Process<TSource>(IObservable<TSource> source)

Parameters

source IObservable<TSource>

The source sequence to schedule notifications for.

Returns

IObservable<TSource>

An observable sequence where all notifications are sent on the specified scheduler.

Type Parameters

TSource

The type of the elements in the source sequence.