【问题标题】:Azure mobile services offline synchronisationAzure 移动服务离线同步
【发布时间】:2017-05-29 01:29:57
【问题描述】:

我正在尝试从 Xamarin.iOS 应用程序进行一些离线同步。当我在 IMobileServiceSyncTable 上调用 PullAsync 时,调用永远不会返回。

我尝试过使用常规的 IMobileServiceTable,它似乎工作正常。同步表似乎对我不起作用

不起作用的代码:

var client = new MobileServiceClient(ApiUrl);

var store = new MobileServiceSQLiteStore("syncstore.db");
store.DefineTable<Entity>();

await client.SyncContext.InitializeAsync(store);
table = client.GetSyncTable<Entity>();
try
{
    await table.PullAsync("all", table.CreateQuery());
}
catch (Exception e)
{
    Debug.WriteLine(e.StackTrace);
}

return await table.ToListAsync();

有效的代码:

var client = new MobileServiceClient(configuration.BaseApiUrl);
return await table.ToListAsync();

谁能指出似乎有问题的地方?我没有得到任何异常或任何指示我的方向 - 它永远不会完成。

更新 1: 看到人们遇到类似问题的其他一些 SO 问题,因为他们在调用堆栈中的某个位置没有等待,而是执行了 Task.Result 或 Task.Wait()。但是,我确实在整个链条中都在等待这个电话。这是例如我编写的单元测试具有与上述完全相同的行为。挂起,永不返回。

[Fact]
public async Task GetAllAsync_ReturnsData()
{
    var result = await sut.GetAllAsync();
    Assert.NotNull(result);
}

更新 2: 我一直在嗅探单元测试发送的请求。它似乎挂起,因为它不断地反复执行 http-request 数百次并且从未退出该操作。

【问题讨论】:

    标签: xamarin.ios azure-mobile-services


    【解决方案1】:

    终于!我找到了问题。

    问题是服务器在 GetAll 操作中返回了一个 IEnumerable。相反,它应该是一个 IQueryable

    这个问题的答案为我指明了正确的方向

    IMobileServiceClient.PullAsync deadlock when trying to sync with Azure Mobile Services

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多