NSFileHandle.Notifications.ObserveReadToEndOfFileCompletion Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 ();