5

How can i kill the application in xamarin.mac I cant find this.dispose or Application.Exit in xamarinMac So How can I kill the application in Xamarin Mac

Optimus
  • 2,200
  • 8
  • 37
  • 71

3 Answers3

11
NSApplication.SharedApplication.Terminate(this)

or from static methods

NSApplication.SharedApplication.Terminate(NSApplication.SharedApplication);
ulmer-morozov
  • 1,306
  • 14
  • 13
1

You should use NSApplication.Terminate.

http://macapi.xamarin.com/?link=M%3aMonoMac.AppKit.NSApplication.Terminate

according to

How to quit itself in Objective-C application?

Community
  • 1
  • 1
Lex Li
  • 60,503
  • 9
  • 116
  • 147
0

I was able to just use Quit in the application class itself. So as part of the application, I created a page and when that page closed, I called quit. Here is my example:

public App()
{
    InitializeComponent();

    if (Device.RuntimePlatform == Device.iOS)
        MainPage = new MainPage();
    else
        MainPage = new NavigationPage(new MainPage());
    MainPage.Disappearing += MainPage_Disappearing;
}
void MainPage_Disappearing(object sender, EventArgs e)
{
    this.Quit();
}
Rob W
  • 1
  • 2