Freigeben über


AVCaptureDevice.Notifications.ObserveWasConnected Methode

Definition

Überlädt

ObserveWasConnected(EventHandler<NSNotificationEventArgs>)

Stark typisierte Benachrichtigung für die WasConnectedNotification Konstante.

ObserveWasConnected(NSObject, EventHandler<NSNotificationEventArgs>)

Stark typisierte Benachrichtigung für die WasConnectedNotification Konstante.

ObserveWasConnected(EventHandler<NSNotificationEventArgs>)

Stark typisierte Benachrichtigung für die WasConnectedNotification Konstante.

public static Foundation.NSObject ObserveWasConnected (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveWasConnected : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parameter

handler
EventHandler<NSNotificationEventArgs>

Methode, die aufgerufen wird, wenn die Benachrichtigung bereitgestellt wird.

Gibt zurück

Tokenobjekt, das verwendet werden kann, um den Empfang von Benachrichtigungen zu beenden, indem es entweder entfernt oder an übergeben wird RemoveObservers(IEnumerable<NSObject>)

Hinweise

Das folgende Beispiel zeigt, wie Sie diese Methode in Ihrem Code verwenden können.

//
// Lambda style
//

// listening
notification = AVCaptureDevice.Notifications.ObserveWasConnected ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);
});

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

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

void Setup ()
{
    notification = AVCaptureDevice.Notifications.ObserveWasConnected (Callback);
}

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

Gilt für:

ObserveWasConnected(NSObject, EventHandler<NSNotificationEventArgs>)

Stark typisierte Benachrichtigung für die WasConnectedNotification Konstante.

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

Parameter

objectToObserve
NSObject

Das spezifische zu beobachtende Objekt.

handler
EventHandler<NSNotificationEventArgs>

Der Handler, der auf die Benachrichtigung reagiert, wenn sie auftritt.

Gibt zurück

Tokenobjekt, das verwendet werden kann, um den Empfang von Benachrichtigungen zu beenden, indem es entweder entfernt oder an übergeben wird RemoveObservers(IEnumerable<NSObject>)

Hinweise

Diese Methode kann verwendet werden, um Benachrichtigungen zu abonnieren WasConnectedNotification .

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

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

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

Gilt für: