Share via


NSFileHandle.Notifications.ObserveReadCompletion Method

Definition

Overloads

ObserveReadCompletion(EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadCompletionNotification constant.

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

Parameters

handler
EventHandler<NSFileHandleReadEventArgs>

The handler that responds to the notification when it occurs.

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 to ReadCompletionNotification notifications.

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

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

Applies to

ObserveReadCompletion(NSObject, EventHandler<NSFileHandleReadEventArgs>)

Strongly typed notification for the ReadCompletionNotification constant.

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

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSFileHandleReadEventArgs>

The handler that responds to the notification when it occurs.

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 to ReadCompletionNotification notifications.

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

Applies to