IObserver<T>.OnCompleted 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
通知觀察者,提供者已完成傳送推播通知。
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 方法可以選擇性地呼叫 DisposeIDisposable 方法時 IObservable<T>.Subscribe 傳回給觀察者的 方法。