Share via


NSWorkspace.Notifications.ObserveWillUnmount Method

Definition

Overloads

ObserveWillUnmount(EventHandler<NSWorkspaceMountEventArgs>)

Strongly typed notification for the WillUnmountNotification constant.

public static Foundation.NSObject ObserveWillUnmount(EventHandler<AppKit.NSWorkspaceMountEventArgs> handler);
static member ObserveWillUnmount : EventHandler<AppKit.NSWorkspaceMountEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSWorkspaceMountEventArgs>

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

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

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

Applies to

ObserveWillUnmount(NSObject, EventHandler<NSWorkspaceMountEventArgs>)

Strongly typed notification for the WillUnmountNotification constant.

public static Foundation.NSObject ObserveWillUnmount(Foundation.NSObject objectToObserve, EventHandler<AppKit.NSWorkspaceMountEventArgs> handler);
static member ObserveWillUnmount : Foundation.NSObject * EventHandler<AppKit.NSWorkspaceMountEventArgs> -> Foundation.NSObject

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSWorkspaceMountEventArgs>

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

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

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

Applies to