Daqi Pei
Daqi Pei

Reputation: 369

Metro App can no longer be programmatically killed?

I'm new to Win 8 Metro application development, and discovered that lots of things seem to be changed from the classic WPF.

What troubles me the most is that there's no way to close the app. This is extremely annoying when it comes to debugging the app. Therefore I'm looking at ways to add a "close" button in my app.

However, the old WPF way of:

Application.Current.Shutdown()

no longer exists. And I couldn't find the Process class in System.Diagnostics any more.

Does anyone know how to do this?

Upvotes: 31

Views: 7233

Answers (6)

Vijay Chandak
Vijay Chandak

Reputation: 1

Try this.. It worked

App.Current.Terminate();

Upvotes: -1

Yigang Wu
Yigang Wu

Reputation: 3592

I used crash code to exit Windows 8 Metro APP. char *p = nullptr; *p = 1;

Upvotes: -3

Norm
Norm

Reputation: 11

This is what I found to close the app.

  App.Current.Exit();

Upvotes: 1

Tormod Fjeldskår
Tormod Fjeldskår

Reputation: 6002

The WinRT reference documentation for the developer preview states that:

CoreApplication.Exit | exit method

Shuts down the app.

Source: http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.core.coreapplication.exit.aspx

Upvotes: 4

Robert Levy
Robert Levy

Reputation: 29073

You're looking for App.Current.Exit()

Upvotes: 32

Jay
Jay

Reputation: 2141

As far as I know you can't close a Metro app (by design) (using the Task-Manager is the only option that works) and as far as I know there is no way to exit a Metro app programatically (by design too).

You could try to throw an unhandled exception (I wouldn't recommend that).

Upvotes: 0

Related Questions