,System.Reactive.Concurrency.IScheduler)} ,System.Threading.SynchronizationContext)}
Synchronization.SubscribeOn(IObservable, IScheduler) method¶
Defined in
Type: Synchronization
Namespace: System.Reactive.Concurrency
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, IScheduler scheduler) - 2.
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
1. Overload¶
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, IScheduler scheduler)
Summary: Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence. |
scheduler | [IScheduler](# | Scheduler to perform subscription and unsubscription actions on. |
Returns: IObservable
Remarks
Only the side-effects of subscribing to the source sequence and disposing subscriptions to the source sequence are run on the specified scheduler. In order to invoke observer callbacks on the specified scheduler, e.g. to offload callback processing to a dedicated thread, use ObserveOn.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or scheduler is null. |
2. Overload¶
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
Summary: Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence. |
context | SynchronizationContext | Synchronization context to perform subscription and unsubscription actions on. |
Returns: IObservable
Remarks
Only the side-effects of subscribing to the source sequence and disposing subscriptions to the source sequence are run on the specified synchronization context. In order to invoke observer callbacks on the specified synchronization context, e.g. to post callbacks to a UI thread represented by the synchronization context, use ObserveOn.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or context is null. |