IObserver<T>.OnCompleted Method ()

.NET Framework (current version)
 

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

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

void OnCompleted()

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.

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();
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: