Closing an application in MonoMac

I am trying to disable the MonoMac application using Environment.Exit(0). However, this call does not return for some reason. This is no exception. When I execute a function in the direct MonoDevelop window, time is running out.

I have no idea how to go about debugging this. I thought Environment.Exit was killing the process ...

+5
source share
2 answers

Instead, you should use NSApplication.Terminate .

Note that this method can invoke the application delegate (if one is defined) to confirm completion (see NSApplicationDelegate.ApplicationShouldTerminate ).

+6

AppDelegate.cs.

public override NSApplicationTerminateReply ApplitionShouldTerminate(NSApplication sender) 
{
    mainWindowController.Window.Close();
    return NSApplicationTerminateReply.Now;
}

public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
{
    return true;
}
+3

All Articles