Xaml 背景任务中的Azure MobileService

Xaml 背景任务中的Azure MobileService,xaml,windows-phone-8.1,azure-mobile-services,background-task,Xaml,Windows Phone 8.1,Azure Mobile Services,Background Task,我的问题很简单:我们可以在后台任务中使用移动服务吗?(WP 8.1 XAML) 我有一个通用应用程序连接到Azure的MobileService,我想让BackgroundTask同步我远程数据库的数据 那么,这可能吗 public sealed class BackgroundTask : IBackgroundTask { public async void Run(IBackgroundTaskInstance taskInstance) { Backgro

我的问题很简单:我们可以在后台任务中使用移动服务吗?(WP 8.1 XAML)

我有一个通用应用程序连接到Azure的MobileService,我想让BackgroundTask同步我远程数据库的数据

那么,这可能吗

public sealed class BackgroundTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
        //Connect to mobile service and add data
        deferral.Complete();
    }
}
我无法添加对我的WP项目的引用,因此如何获取App.MobileServiceClient? 我的BackgroundTask项目是一个Windows运行时组件

编辑:

我已经通过管理nuGet软件包添加了对Windows Azure移动服务的引用,现在我可以声明一个mobileService,但是当我想实例化它时,我遇到了以下错误:

BACKGROUNDTASKHOST.EXE' has exited with code 1 (0x1).
这就是我的代码现在的样子:

public sealed class BackgroundTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
        Microsoft.WindowsAzure.MobileServices.MobileServiceClient lolServiceMobileClient =
                new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
                "https://myservicemobile.azure-mobile.net/",
                "myKey");
        deferral.Complete();
    }
}
这是我添加的参考:

编辑2
我仍在寻找解决方案,我现在想知道,可能是因为我超出了后台任务允许使用的内存量吗?

我不是后台任务专家,但你确实可以在那里使用移动服务SDK。通过使用应用程序设置在两个进程之间锁定,确保后台任务不会干扰应用程序