Share via


NSExtensionContext.Notifications.ObserveHostDidEnterBackground Método

Definición

Sobrecargas

ObserveHostDidEnterBackground(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la HostDidEnterBackgroundNotification constante.

ObserveHostDidEnterBackground(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la HostDidEnterBackgroundNotification constante.

ObserveHostDidEnterBackground(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la HostDidEnterBackgroundNotification constante.

public static Foundation.NSObject ObserveHostDidEnterBackground (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveHostDidEnterBackground : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

handler
EventHandler<NSNotificationEventArgs>

Método que se invoca cuando se publica la notificación.

Devoluciones

Objeto token que se puede usar para dejar de recibir notificaciones mediante su eliminación o su paso a RemoveObservers(IEnumerable<NSObject>)

Comentarios

Este método se puede usar para suscribirse HostDidEnterBackgroundNotification a las notificaciones.

// Listen to all notifications posted for any object
var token = NSExtensionContext.Notifications.ObserveHostDidEnterBackground ((notification) => {
	Console.WriteLine ("Observed HostDidEnterBackgroundNotification!");
};

// Listen to all notifications posted for a single object
var token = NSExtensionContext.Notifications.ObserveHostDidEnterBackground (objectToObserve, (notification) => {
	Console.WriteLine ($"Observed HostDidEnterBackgroundNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Se aplica a

ObserveHostDidEnterBackground(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la HostDidEnterBackgroundNotification constante.

public static Foundation.NSObject ObserveHostDidEnterBackground (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveHostDidEnterBackground : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

objectToObserve
NSObject

Objeto que se va a observar.

handler
EventHandler<NSNotificationEventArgs>

Método que se invoca cuando se publica la notificación.

Devoluciones

Objeto token que se puede usar para dejar de recibir notificaciones mediante su eliminación o su paso a RemoveObservers(IEnumerable<NSObject>)

Comentarios

Este método se puede usar para suscribirse HostDidEnterBackgroundNotification a las notificaciones.

// Listen to all notifications posted for any object
var token = NSExtensionContext.Notifications.ObserveHostDidEnterBackground ((notification) => {
	Console.WriteLine ("Observed HostDidEnterBackgroundNotification!");
};

// Listen to all notifications posted for a single object
var token = NSExtensionContext.Notifications.ObserveHostDidEnterBackground (objectToObserve, (notification) => {
	Console.WriteLine ($"Observed HostDidEnterBackgroundNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Se aplica a