C# Windows Azure移动服务数据获取已完成
我可以使用Windows Azure移动服务获取数据。我想做的是在我的应用程序中加入“加载…”。在我能做之前,我必须知道数据提取何时完成 问题是“我怎么知道这个?” 提前感谢, 一些代码C# Windows Azure移动服务数据获取已完成,c#,azure,windows-phone-8,async-await,azure-mobile-services,C#,Azure,Windows Phone 8,Async Await,Azure Mobile Services,我可以使用Windows Azure移动服务获取数据。我想做的是在我的应用程序中加入“加载…”。在我能做之前,我必须知道数据提取何时完成 问题是“我怎么知道这个?” 提前感谢, 一些代码 私人移动服务收集项目; 私有IMobileServiceTable itemTable=App.MobileService.GetTable(); items=wait itemtableosu.Where(todoItem=>todoItem.Complete==false); 在ToCollectionAs
私人移动服务收集项目;
私有IMobileServiceTable itemTable=App.MobileService.GetTable();
items=wait itemtableosu.Where(todoItem=>todoItem.Complete==false);
在ToCollectionAsync
之后,“returns”是在完成时。使用wait
建立一个状态机,当该操作完成时,该状态机在UI线程上异步执行下一行。您只需执行以下操作:
items = await itemTablosu.Where(todoItem => todoItem.Complete == false).ToCollectionAsync();
myLoadingControl.Visibility = Visibility.Collapsed;
这假设
ToCollectionAsync()
是从UI线程调用的(例如,单击按钮、加载的处理程序、导航到覆盖的等)。谢谢,它起作用了!我不知道为什么,但我本来希望找到一个“已完成”的事件方式。很抱歉我的疏忽。是的,他们已经“占用”了“异步”基于任务的模式的后缀。您可以使用从异步方法返回的Task
执行更复杂的操作,但新模式不使用事件。
items = await itemTablosu.Where(todoItem => todoItem.Complete == false).ToCollectionAsync();
myLoadingControl.Visibility = Visibility.Collapsed;