Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IObserver<T>.OnCompleted Method

Definition

Namespace:
System
Assemblies:
mscorlib.dll, System.Runtime.dll
Assemblies:
netstandard.dll, System.Runtime.dll
Assembly:
System.Runtime.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
IObserver.cs
Source:
IObserver.cs
Source:
ThreadPoolBoundHandle.Unix.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Notifies the observer that the provider has finished sending push-based notifications.

public:
 void OnCompleted();
public void OnCompleted();
abstract member OnCompleted : unit -> unit
Public Sub OnCompleted ()

Examples

The following example provides an implementation of the OnCompleted method in a latitude/longitude tracking application. The method simply reports that no further data is available and calls the provider's IDisposable.Dispose implementation. See the Example section of the IObserver<T> topic for the complete example.

public virtual void OnCompleted()
{
 Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", this.Name);
 this.Unsubscribe();
}
member this.OnCompleted() =
 printfn $"The Location Tracker has completed transmitting data to {name}."
 this.Unsubscribe()
Public Overridable Sub OnCompleted() Implements System.IObserver(Of Location).OnCompleted
 Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", Me.Name)
 Me.Unsubscribe()
End Sub

Remarks

When the observer's OnCompleted implementation is called, the OnCompleted method can optionally call the Dispose method of the IDisposable object that was returned to the observer when it called the IObservable<T>.Subscribe method.

Applies to


Feedback

Was this page helpful?