Search code examples
windows-phone-7background-agents

How to detect if the main app is running from a background agent


I'm working on a WP7.5 app where I use a background agent to update tiles in the background (when the app is not running).

In the OnInvoke method of the agent, is there a way to know if the main app is currently running ?

I'd like to detect that in order to NOT updating the tiles if the app is running because I already udpate them when the app exits.

Thank you.


Solution

  • Your only choice is to write use isolated storage to communicate, since it's shared by both agent and application.

    Have the main application create a blank file on startup, and delete it when it closes. Your agent can then determine if the application is running by checking the existance of that file.