IObserver<T>.OnCompleted 方法

定义

通知观察者提供程序已完成发送基于推送的通知。

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

示例

以下示例在纬度/经度跟踪应用程序中提供了 方法的 OnCompleted 实现。 方法只是报告没有进一步的数据可用,并调用提供程序的 IDisposable.Dispose 实现。 有关完整示例, IObserver<T> 请参阅主题的示例部分。

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

注解

调用观察者的OnCompleted实现时,OnCompleted方法可以选择性地调用Dispose在调用 IObservable<T>.Subscribe 方法IDisposable时返回给观察者的 对象的 方法。

适用于