문제

I'm trying to shutdown a MonoMac application by using Environment.Exit(0). However, this call for some reason does not return. It does not throw an exception, either. When I execute the function in the immediate window in MonoDevelop, it times out.

I have no idea how to approach debugging this. I thought that Environment.Exit kills the process...

도움이 되었습니까?

해결책

You should use the NSApplication.Terminate method instead.

Note that this method may call the application delegate (if defined) to confirm the termination (See NSApplicationDelegate.ApplicationShouldTerminate).

다른 팁

You may add two override functions in AppDelegate.cs.

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

public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
{
    return true;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top