NSFileHandle.Notifications.ObserveReadCompletion Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Sobrecargas
ObserveReadCompletion(EventHandler<NSFileHandleReadEventArgs>) |
Notificación fuertemente tipada para la ReadCompletionNotification constante. |
ObserveReadCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>) |
Notificación fuertemente tipada para la ReadCompletionNotification constante. |
ObserveReadCompletion(EventHandler<NSFileHandleReadEventArgs>)
Notificación fuertemente tipada para la ReadCompletionNotification constante.
public static Foundation.NSObject ObserveReadCompletion (EventHandler<Foundation.NSFileHandleReadEventArgs> handler);
static member ObserveReadCompletion : EventHandler<Foundation.NSFileHandleReadEventArgs> -> Foundation.NSObject
Parámetros
- handler
- EventHandler<NSFileHandleReadEventArgs>
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 los desarrolladores pueden usar este método en su código:
//
// Lambda style
//
// listening
notification = NSFileHandle.Notifications.ObserveReadCompletion ((sender, args) => {
/* Access strongly typed args */
Console.WriteLine ("Notification: {0}", args.Notification);
Console.WriteLine ("AvailableData", args.AvailableData);
Console.WriteLine ("UnixErrorCode", args.UnixErrorCode);
});
// To stop listening:
notification.Dispose ();
//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSFileHandleReadEventArgs args)
{
// Access strongly typed args
Console.WriteLine ("Notification: {0}", args.Notification);
Console.WriteLine ("AvailableData", args.AvailableData);
Console.WriteLine ("UnixErrorCode", args.UnixErrorCode);
}
void Setup ()
{
notification = NSFileHandle.Notifications.ObserveReadCompletion (Callback);
}
void Teardown ()
{
notification.Dispose ();
}
Se aplica a
ObserveReadCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)
Notificación fuertemente tipada para la ReadCompletionNotification constante.
public static Foundation.NSObject ObserveReadCompletion (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSFileHandleReadEventArgs> handler);
static member ObserveReadCompletion : Foundation.NSObject * EventHandler<Foundation.NSFileHandleReadEventArgs> -> Foundation.NSObject
Parámetros
- objectToObserve
- NSObject
Objeto que se va a observar.
- handler
- EventHandler<NSFileHandleReadEventArgs>
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 ReadCompletionNotification a las notificaciones.
// Listen to all notifications posted for any object
var token = NSFileHandle.Notifications.ObserveReadCompletion ((notification) => {
Console.WriteLine ("Observed ReadCompletionNotification!");
};
// Listen to all notifications posted for a single object
var token = NSFileHandle.Notifications.ObserveReadCompletion (objectToObserve, (notification) => {
Console.WriteLine ($"Observed ReadCompletionNotification for {nameof (objectToObserve)}!");
};
// Stop listening for notifications
token.Dispose ();