Partager via


NKIssue.Notifications.ObserveDownloadCompleted Méthode

Définition

Surcharges

ObserveDownloadCompleted(EventHandler<NSNotificationEventArgs>)

Notification fortement typée pour la DownloadCompletedNotification constante.

ObserveDownloadCompleted(NSObject, EventHandler<NSNotificationEventArgs>)

Notification fortement typée pour la DownloadCompletedNotification constante.

ObserveDownloadCompleted(EventHandler<NSNotificationEventArgs>)

Notification fortement typée pour la DownloadCompletedNotification constante.

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

Paramètres

handler
EventHandler<NSNotificationEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

L’exemple suivant montre comment utiliser cette méthode dans votre code

//
// Lambda style
//

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

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

S’applique à

ObserveDownloadCompleted(NSObject, EventHandler<NSNotificationEventArgs>)

Notification fortement typée pour la DownloadCompletedNotification constante.

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

Paramètres

objectToObserve
NSObject

Objet à observer.

handler
EventHandler<NSNotificationEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

Cette méthode peut être utilisée pour DownloadCompletedNotification s’abonner aux notifications.

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

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

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

S’applique à