I have background task in my app, which runs every 15 minutes (when on lock screen). Is it possible to detect if my app is running when background task is executing ? I'd like to skip background task execution in such case, to avoid concurrency problems.
You can't detect when your app is running from a background task but you can detect when the background task is running from your app with the BackgroundTaskRegistration Progress and Completed events.
This sample covers everything you should need. http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9
Because both the app and the background task have access to app data, have the app store a flag in ApplicationData.localSettings when it's activated, clearing the flag when it's suspended, and resetting the flag when it's resumed. The background task can then check that flag when it starts and make the decision from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With