【发布时间】:2013-12-27 18:01:19
【问题描述】:
我正在使用便携式版本的 mvvmlight 开发一个 win phone 8 应用程序。
在创建 ViewModel 时,我必须调用使用 Azure 移动服务 Sdk 从 Azure 移动服务读取数据的服务。
Sdk api 使用 async /await 来完成工作,我无法在 ViewModel 或 Service costructor 中进行异步调用。
代码是这样的:
public ListaArtiModel(INavigate navigationService)
{
_navigationService = navigationService;
ArtiMarzialiService artiService = new ArtiMarzialiService();
List<ArteMarziale>risultato = await artiService.ListaArti();
}
编译器告诉
错误 1 'await' 运算符只能在异步方法中使用。考虑使用“异步”修饰符标记此方法并将其返回类型更改为“任务”。
我该如何解决这个问题? 谢谢, 卢卡
【问题讨论】:
标签: azure mvvm asynchronous windows-phone-8 mvvm-light