我有一个 Windows Phone 8 项目,我希望在其中有一个响应 NetworkStateChange 系统触发器的后台任务。
我发现了这个问题:Windows Phone 8.1 Background Task - Can't Debug and won't fire,下载并重新实现了解决方案(http://1drv.ms/1qCPLMY),并在一些帮助下,结果很好。
我做了这个简单的任务:使用 Windows.ApplicationModel.Background;
namespace FlexCheck.Tasks
{
public sealed class BackgroundTask : IBackgroundTask
{
BackgroundTaskDeferral _deferral = null;
public void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
_deferral.Complete();
}
}
}
为了编译它,我需要目标是 Windows Phone 8.1。但后来我无法从我的 Windows 8 项目中引用。
问题:我能以某种方式解决这个问题吗?或者是否有可以在 Windows phone 8 上使用的等效 IBackgroundTask?