Pergunta

Here's an excerpt from a link I read:

When the user moves an app to the background, Windows waits a few seconds to see whether the user immediately switches back to the app. If the user does not switch back, Windows suspends the app.

If an app has registered an event handler for the Suspending | suspending event, this event handler is called right before the app is suspended.

In my app code file App.xaml.cs, I have overridden method OnSuspending. However, in debugging the app, this method doesn't seem to get called when I switch away from it or open another app. I have waited for a while as well and nothing happens. If I use the close gesture or hit Alt+F4, eventually the method is invoked as expected. Am I missing something here? Is the app not supposed to be suspended when you navigate away from it?

Foi útil?

Solução

When debugging, you'll need to use the Suspend, Resume, and Suspend and Shutdown on the Debug Location toolbar within Visual Studio to test your application's response to those events. I find it easier to do so when running in the simulator.

You can read more about it here and you might also take a look at more information like this available from the App Builder program.

Outras dicas

Apps do not get suspended when you are debugging them. They will only get suspended outside of the debugger.

To force your app to get suspended when debugging, see this answer: https://stackoverflow.com/a/14077958/1822514

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top