3

In Windows 10 universal application which is running in desktop environment, in what cases can be Application.Suspending event fired? One case is closing the app (for example with Alt+F4), are there any other cases? I thought that Alt+Tab would also fire this event but strangely that's not the case, why?

xcoder37
  • 499
  • 6
  • 21

1 Answers1

4

Application.Suspending on Mobile will fire whenever the user navigates to another screen via the task switcher, hitting the back button from the root page, hitting home, on when a phone call is received etc.

On Desktop, it will fire whenever the application is minimized.

However, it will ALSO fire on both desktop AND mobile when the app is on the way to being terminated for any reason.

On Desktop this is when alt+f4 is hit, or the window is closed.

On Mobile, by the time the window is being terminated (low memory or killed in switcher), the Application.Suspending event will have already fired.

Alt+Tab on desktop will not suspend the event as the window is still running as a live preview because it is visible to the user.

Check out this video from Microsoft Virtual Academy for a great look at the Windows Universal App lifecycle, or check out the App Lifecycle docs from MSDN.

Hope this helps

rcbevans
  • 7,101
  • 4
  • 30
  • 46
  • Thank you, this helps but one thing seems not to fit here. On desktop, when I minimize my app, this event doesn't fire (I run my app from Visual Studio through F5, haven't checked from binary but I think it should matter). Do you have any idea why? It fires only when I terminate app. I need to fully understand this event in order to handle it properly. – xcoder37 Sep 30 '15 at 13:21
  • A bit late, but that's because F5 will debug your app and Windows does not suspend an app while it is being debugged (see [this answer](http://stackoverflow.com/a/24103734/1438809)). – Felix Apr 07 '16 at 20:31