Skip to content

)} ,System.Object)}

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

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.

Returns: IObservable -- The source sequence whose outgoing calls to observers are synchronized.

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

TypeCondition
System.ArgumentNullExceptionsource 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

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
gateobjectGate object to synchronize each observer call on.

Returns: IObservable -- The source sequence whose outgoing calls to observers are synchronized on the given gate object.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or gate is null.