Düzenle

Aracılığıyla paylaş


NSFileHandle.Notifications.ObserveConnectionAccepted Method

Definition

Overloads

ObserveConnectionAccepted(EventHandler<NSFileHandleConnectionAcceptedEventArgs>)

Strongly typed notification for the ConnectionAcceptedNotification constant.

ObserveConnectionAccepted(NSObject, EventHandler<NSFileHandleConnectionAcceptedEventArgs>)

Strongly typed notification for the ConnectionAcceptedNotification constant.

ObserveConnectionAccepted(EventHandler<NSFileHandleConnectionAcceptedEventArgs>)

Strongly typed notification for the ConnectionAcceptedNotification constant.

public static Foundation.NSObject ObserveConnectionAccepted (EventHandler<Foundation.NSFileHandleConnectionAcceptedEventArgs> handler);
static member ObserveConnectionAccepted : EventHandler<Foundation.NSFileHandleConnectionAcceptedEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSFileHandleConnectionAcceptedEventArgs>

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.ObserveConnectionAccepted ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("NearSocketConnection", args.NearSocketConnection);
    Console.WriteLine ("UnixErrorCode", args.UnixErrorCode);
});

// To stop listening:
notification.Dispose ();

//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSFileHandleConnectionAcceptedEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("NearSocketConnection", args.NearSocketConnection);
    Console.WriteLine ("UnixErrorCode", args.UnixErrorCode);
}

void Setup ()
{
    notification = NSFileHandle.Notifications.ObserveConnectionAccepted (Callback);
}

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

Applies to

ObserveConnectionAccepted(NSObject, EventHandler<NSFileHandleConnectionAcceptedEventArgs>)

Strongly typed notification for the ConnectionAcceptedNotification constant.

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

Parameters

objectToObserve
NSObject

The object to observe.

handler
EventHandler<NSFileHandleConnectionAcceptedEventArgs>

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 ConnectionAcceptedNotification notifications.

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

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

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

Applies to