Bug 46526 - On UWP, the expected application lifecycle events for suspend and resume are not fired
Summary: On UWP, the expected application lifecycle events for suspend and resume are ...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-11-06 00:45 UTC by John Hardman
Modified: 2016-11-13 18:09 UTC (History)
3 users (show)

Tags: Application lifecycle OnSleep OnResume UWP
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Hardman 2016-11-06 00:45:29 UTC
On UWP (tested on both phone and desktop), the OnSleep and OnResume methods described in the XF documentation at the following URL, are not executed:

Another dev has reported the same thing on the forums at:

Ideally, those methods should get called. But, if they are not going to be called, the documentation should be updated to match the actual behavior.

For info, there is some useful information about lifecycle on Windows 10 at the following address:
Comment 1 John Hardman 2016-11-06 00:53:30 UTC
As per the thread mentioned above, there only seems to be one scenario when OnSleep is called on UWP, described by the author of the forum post as follows:
"The only time the onsleep fires is when i hold the back button and terminate the app using the X"
Comment 2 Paul DiPietro [MSFT] 2016-11-07 17:38:51 UTC
From that MSDN page:

"A note about debugging using Visual Studio: Visual Studio prevents Windows from suspending an app that is attached to the debugger. This is to allow the user to view the Visual Studio debug UI while the app is running. When you're debugging an app, you can send it a suspend event using Visual Studio. Make sure the Debug Location toolbar is being shown, then click the Suspend icon."

The events fire internally on one of our control gallery projects when using the aforementioned toolbar, so I'd be led to believe that this is the cause. I presume OnSleep firing due to app termination would be due to the debugger no longer running.
Comment 3 John Hardman 2016-11-13 18:09:22 UTC
@Paul DiPietro - Yes, you are correct. Please excuse my brain fade :-)

Setting to Resolved/Invalid