Table of Contents

Class SubscribeOn

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.

An observable sequence, and the chain of operators that are applied to it, will often do its work and notify any downstream observers on the same thread on which the subscribe action is called. The SubscribeOn operator changes this behavior by specifying a different scheduler for the subscribe (and unsubscribe) action.

Marble diagram

As shown in the diagram, the SubscribeOn operator can affect the ultimate source of notifications, no matter where in the chain of operators it is placed, as it changes the thread for the entire upstream subscribe call. By contrast, the ObserveOn operator changes only the scheduler on which notifications are sent, which affects only downstream operators.

Warning

Hot observable sources such as hardware devices often impose their own execution schedulers, e.g. by hooking notifications to device driver callbacks or interrupts. In these situations it is usually more appropriate to control concurrency using the ObserveOn operator.

public class SubscribeOn : Combinator
Inheritance
SubscribeOn
Inherited Members

Remarks

This operator is not commonly used.

Properties

Scheduler

Gets or sets a value specifying the scheduler on which to run subscription and unsubscription actions.

[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>)

Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.

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

Parameters

source IObservable<TSource>

The observable sequence to wrap.

Returns

IObservable<TSource>

An observable sequence where subscription and unsubscription logic are run on the specified scheduler.

Type Parameters

TSource

The type of the elements in the source sequence.

See Also