Share via


NSMetadataQuery.Notifications.ObserveGatheringProgress Método

Definición

Sobrecargas

ObserveGatheringProgress(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la GatheringProgressNotification constante.

ObserveGatheringProgress(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la GatheringProgressNotification constante.

ObserveGatheringProgress(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la GatheringProgressNotification constante.

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

Parámetros

handler
EventHandler<NSNotificationEventArgs>

Método para invocar cuando se publica la notificación.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

En el ejemplo siguiente se muestra cómo puede usar este método en el código.

//
// Lambda style
//

// listening
notification = NSMetadataQuery.Notifications.ObserveGatheringProgress ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);
});

// To stop listening:
notification.Dispose ();

//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSNotificationEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);
}

void Setup ()
{
    notification = NSMetadataQuery.Notifications.ObserveGatheringProgress (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

Se aplica a

ObserveGatheringProgress(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la GatheringProgressNotification constante.

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

Parámetros

objectToObserve
NSObject

Objeto que se va a observar.

handler
EventHandler<NSNotificationEventArgs>

Método para invocar cuando se publica la notificación.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

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

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

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

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

Se aplica a