Поделиться через


AVCaptureSession.Notifications.ObserveDidStopRunning Метод

Определение

Перегрузки

ObserveDidStopRunning(EventHandler<NSNotificationEventArgs>)

Строго типизированное уведомление для константы DidStopRunningNotification .

ObserveDidStopRunning(NSObject, EventHandler<NSNotificationEventArgs>)

Строго типизированное уведомление для константы DidStopRunningNotification .

ObserveDidStopRunning(EventHandler<NSNotificationEventArgs>)

Строго типизированное уведомление для константы DidStopRunningNotification .

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

Параметры

handler
EventHandler<NSNotificationEventArgs>

Метод, вызываемый при публикации уведомления.

Возвращаемое значение

Объект токена, который можно использовать для прекращения получения уведомлений путем удаления или передачи в RemoveObservers(IEnumerable<NSObject>)

Комментарии

В следующем примере показано, как использовать этот метод в коде.

//
// Lambda style
//

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

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

Применяется к

ObserveDidStopRunning(NSObject, EventHandler<NSNotificationEventArgs>)

Строго типизированное уведомление для константы DidStopRunningNotification .

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

Параметры

objectToObserve
NSObject

Конкретный объект для наблюдения.

handler
EventHandler<NSNotificationEventArgs>

Обработчик, который реагирует на уведомление при его возникновении.

Возвращаемое значение

Объект токена, который можно использовать для прекращения получения уведомлений путем удаления или передачи в RemoveObservers(IEnumerable<NSObject>)

Комментарии

Этот метод можно использовать для подписки на DidStopRunningNotification уведомления.

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

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

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

Применяется к