Make it stop! (Game.Exit deprecated?)

Yup, I’m tinkering with Universal Apps so there’s probably going to be quite a few noob-esque questions from me for a while!

At the moment, I’m trying to make a basic test platform - images, fonts, sound effects & music from the content builder, correct input handling dependent on platform, that sort of thing… it’s going pretty well, so kudos to the team!

But when I put my usual Game.Exit call in the Update method, I got a warning stating that this had been deprecated.

What’s the correct practice for exiting a universal app on both desktop and phone? Obviously, shared code would be preferable…

Cheers.

The WP8.1 version of MonoGame is still very much work in progress. I have implemented some things recently, including Game.Exit(). Please use the latest version from the develop branch of GitHub.

Hi Nezz,

Just to check - the version of Monogame I’ve got installed was the latest TeamCity build only a couple of days ago - would your changes not have been included in this?

I’m just keen to avoid the tangle I got into with my last project where I ended up having several different versions of Monogame, with projects added into my solution and so forth.

Thanks!

I have never used the installer versions of MonoGame. My pull request was merged 13 days ago:

This should contain the change:
http://teamcity.monogame.net/viewLog.html?buildTypeId=MonoGame_DevelopWin&buildId=lastSuccessful&tab=artifacts&buildBranch=<default>&guest=1

Ah, miscommunication on my part, I think - I’ve got the Game.Exit call in the Game1 class in the shared project - and the error message about the method’s obsolescence is coming from the Windows Project, not the Windows Phone one:

Error 1 ‘Microsoft.Xna.Framework.Game.Exit()’ is obsolete: ‘“This platform’s policy does not allow programmatically closing.”’ C:\Leda Entertainment\Tests\ContentTest\ContentTest\ContentTest.Shared\Game1.cs 83 41 ContentTest.Windows

So I guess this is a trait of Windows Store apps - they never “quit” in the traditional sense?

Yes, that’s correct.

Yeah, for Windows Store Apps, they want you to let Windows manage if an app actually closes, otherwise when the user changes away from it, the app goes into a deactivated state (which is also where you’ll want to put your save state code). Once in a deactivated state Windows may decide to kill it.

For my universal app I just put the Game.Exit() attached to the back button only and surrounded by #if WINDOWS_PHONE_APP and the app compiles fine for both Store and Phone.

According to their guidelines, Windows Store Apps should not have an exit button but rather be managed by the X or pulling the screen down (or in 10 the commands close app).

I’m working on Windows 10 Universal app with Monogame 3.4.
When call Exit method of game instance in GamePage, then navigate to other Page, it still run Update function loop forever.
How can we stop it?
Thank,