Subscribe Method
Collapse the table of content
Expand the table of content

IObservable(Of T).Subscribe Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Subscribes observer to receive notifications.

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

'Declaration
Function Subscribe ( _
	observer As IObserver(Of T) _
) As IDisposable

Parameters

observer
Type: System.IObserver(Of T)
The object that is to receive notifications.

Return Value

Type: System.IDisposable
A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.

The Subscribe method must be called to register an observer for push-based notifications. A typical implementation of the Subscribe method does the following:

  • It stores a reference to the observer in a collection object, such as a List<T> object.

  • It returns a reference to an IDisposable interface. This enables observers to unsubscribe (that is, to stop receiving notifications) before the provider has finished sending them and called the subscriber's OnCompleted method.

At any given time, a particular instance of an IObservable<T> implementation is responsible for handling all subscriptions and notifying all subscribers. Unless the documentation for a particular IObservable<T> implementation indicates otherwise, observers should make no assumptions about the IObservable<T> implementation, such as the order of notifications that multiple observers will receive.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft