Class Synchronization
Provides basic synchronization and scheduling services for observable sequences.
Inherited Members
Namespace: System.Reactive.Concurrency
Assembly: System.Reactive.Core.dll
Syntax
public static class Synchronization
Methods
| Improve this Doc View SourceObserveOn<TSource>(IObservable<TSource>, IScheduler)
Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
Declaration
public static IObservable<TSource> ObserveOn<TSource>(IObservable<TSource> source, IScheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
IScheduler | scheduler | Scheduler to notify observers on. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose observations happen on the specified scheduler. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ObserveOn<TSource>(IObservable<TSource>, SynchronizationContext)
Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
Declaration
public static IObservable<TSource> ObserveOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
SynchronizationContext | context | Synchronization context to notify observers on. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose observations happen on the specified synchronization context. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SubscribeOn<TSource>(IObservable<TSource>, IScheduler)
Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.
Declaration
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, IScheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
IScheduler | scheduler | Scheduler to perform subscription and unsubscription actions on. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
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<TSource>(IObservable<TSource>, IScheduler).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SubscribeOn<TSource>(IObservable<TSource>, SynchronizationContext)
Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context.
Declaration
public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
SynchronizationContext | context | Synchronization context to perform subscription and unsubscription actions on. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
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<TSource>(IObservable<TSource>, SynchronizationContext).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Synchronize<TSource>(IObservable<TSource>)
Wraps the source sequence in order to ensure observer callbacks are properly serialized.
Declaration
public static IObservable<TSource> Synchronize<TSource>(IObservable<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose outgoing calls to observers are synchronized. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Synchronize<TSource>(IObservable<TSource>, Object)
Wraps the source sequence in order to ensure observer callbacks are synchronized using the specified gate object.
Declaration
public static IObservable<TSource> Synchronize<TSource>(IObservable<TSource> source, object gate)
Parameters
Type | Name | Description |
---|---|---|
IObservable<TSource> | source | Source sequence. |
Object | gate | Gate object to synchronize each observer call on. |
Returns
Type | Description |
---|---|
IObservable<TSource> | The source sequence whose outgoing calls to observers are synchronized on the given gate object. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|