Compartir a través de


NSUndoManager.Notifications.ObserveCheckpoint Método

Definición

Sobrecargas

ObserveCheckpoint(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la CheckpointNotification constante.

ObserveCheckpoint(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la CheckpointNotification constante.

ObserveCheckpoint(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la CheckpointNotification constante.

public static Foundation.NSObject ObserveCheckpoint (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveCheckpoint : 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

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

//
// Lambda style
//

// listening
notification = NSUndoManager.Notifications.ObserveCheckpoint ((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 = NSUndoManager.Notifications.ObserveCheckpoint (Callback);
}

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

Se aplica a

ObserveCheckpoint(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la CheckpointNotification constante.

public static Foundation.NSObject ObserveCheckpoint (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveCheckpoint : 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 CheckpointNotification a las notificaciones.

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

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

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

Se aplica a