Compartilhar via


NSFileHandle.Notifications.ObserveReadCompletion Método

Definição

Sobrecargas

ObserveReadCompletion(EventHandler<NSFileHandleReadEventArgs>)

Notificação fortemente tipada para a ReadCompletionNotification constante.

ObserveReadCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)

Notificação fortemente tipada para a ReadCompletionNotification constante.

ObserveReadCompletion(EventHandler<NSFileHandleReadEventArgs>)

Notificação fortemente tipada para a 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 a ser invocado quando a notificação é postada.

Retornos

Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)

Comentários

O exemplo a seguir mostra como os desenvolvedores podem usar esse método em seu 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 ();
}

Aplica-se a

ObserveReadCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)

Notificação fortemente tipada para a 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

O objeto a ser observado.

handler
EventHandler<NSFileHandleReadEventArgs>

Método a ser invocado quando a notificação é postada.

Retornos

Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)

Comentários

Esse método pode ser usado para assinar ReadCompletionNotification notificações.

// 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 ();

Aplica-se a