0

I've got an App with Extended Execution. When I close the App, it runs perfectly fine in the background. But when it is in "background" I need to do some things differently than when the App is visible.

Since I'm extending the Execution session on startup, the OnSuspending Event is never called. Is there any way to check if the App is currently active?

Thank you!

Travis
  • 248
  • 4
  • 11
  • Are you asking only about desktop or also about a mobile version? – Romasz Dec 08 '15 at 21:12
  • Especially about a mobile version, though in an universal app I think its the same? – Travis Dec 08 '15 at 21:45
  • That's what I thought, but I wonder what you mean by 'Extended Execution'? Also how you have checked that it runs perfectly in the background? - you mean that it hasn't been suspended while debugging? - if so, then be aware that while debugging PLM is disabled and your app [simply won't suspend](http://stackoverflow.com/q/24103101/2681948). – Romasz Dec 08 '15 at 22:01
  • I know, because I update serverside data, and can see that this data is being updated. This article https://msdn.microsoft.com/en-us/magazine/mt590969.aspx states "The application will never receive a suspending event while the execution extension is in effect." - so I assume the event never gets called. But how do I now the App has been deactivated? – Travis Dec 09 '15 at 07:28
  • 3
    You can try to use `CoreApplication.GetCurrentView().CoreWindow.Visible` to detect whether your App is visible. But since you want to do something different while in "background", why not use Extended Execution in the OnSuspending Handler instead of using it at startup? – Jay Zuo Dec 09 '15 at 11:00
  • Nice thing this Extended execution - I wasn't aware about his in W10. I would follow what Jay Zuo says. In case you want to track your app's visibility, there is *VisibilityChanged* event in core window, so the app can be notified once it becomes in/visible. – Romasz Dec 09 '15 at 11:12

1 Answers1

0

If you must start the extended execution process when the app is running you could possibly use navigation (or resize?) events that will tell you when you lose (and possibly regain) UI?

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143