Observable.Synchronize(IObservable) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source) - 2.
public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source, object gate)
1. Overload¶
public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source)
Summary: Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently. This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence. |
Returns: IObservable
Remarks
It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
This operator can be used to "fix" a source that doesn't conform to this rule.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
2. Overload¶
public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source, object gate)
Summary: Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object. This overload is useful when writing n-ary query operators, in order to prevent concurrent callbacks from different sources by synchronizing on a common gate object.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence. |
gate | object | Gate object to synchronize each observer call on. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or gate is null. |