Edit

Share via


NSFileHandle.Notifications.ObserveReadToEndOfFileCompletion Method

Definition

Overloads

ObserveReadToEndOfFileCompletion(EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadToEndOfFileCompletionNotification constant.

ObserveReadToEndOfFileCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadToEndOfFileCompletionNotification constant.

ObserveReadToEndOfFileCompletion(EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadToEndOfFileCompletionNotification constant.

public static Foundation.NSObject ObserveReadToEndOfFileCompletion (EventHandler<Foundation.NSFileHandleReadEventArgs> handler);
static member ObserveReadToEndOfFileCompletion : EventHandler<Foundation.NSFileHandleReadEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSFileHandleReadEventArgs>

Method to invoke when the notification is posted.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>)

Remarks

The following example shows how developers can use this method in their code:

//
// Lambda style
//

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

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

Applies to

ObserveReadToEndOfFileCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadToEndOfFileCompletionNotification constant.

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

Parameters

objectToObserve
NSObject

The object to observe.

handler
EventHandler<NSFileHandleReadEventArgs>

Method to invoke when the notification is posted.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>)

Remarks

This method can be used to subscribe for ReadToEndOfFileCompletionNotification notifications.

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

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

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

Applies to