如何检测主应用程序是否正在从后台代理运行 [英] How to detect if the main app is running from a background agent
问题描述
我正在WP7.5应用程序上工作,在该应用程序中,我使用后台代理来更新背景中的图块(当应用程序未运行时).
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).
在代理的OnInvoke方法中,是否有办法知道主应用程序当前是否正在运行?
我想进行检测,以便在应用程序运行时不更新磁贴,因为在应用程序退出时我已经对它们进行了点胶.
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.
谢谢.
推荐答案
您唯一的选择是编写使用隔离存储进行通信,因为它已由代理和应用程序共享.
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.
这篇关于如何检测主应用程序是否正在从后台代理运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!