Windows phone 8 PCLStorage CreateFolderAsync挂起
我正在为我的WP8应用程序使用PCL存储库。我试着用他们网站上的介绍例子 代码:Windows phone 8 PCLStorage CreateFolderAsync挂起,windows-phone-8,Windows Phone 8,我正在为我的WP8应用程序使用PCL存储库。我试着用他们网站上的介绍例子 代码: IFolder rootFolder = FileSystem.Current.LocalStorage; IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists); IFile file = await folder.CreateF
IFolder rootFolder = FileSystem.Current.LocalStorage;
IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists);
IFile file = await folder.CreateFileAsync("answer.txt", CreationCollisionOption.ReplaceExisting);
await file.WriteAllTextAsync("42");
CreateFolderAsync函数挂起,无法执行。我在模拟器和设备上都试过了
我遗漏了什么吗?请进一步查找您的调用堆栈。您几乎肯定会找到对
Task.Wait
或Task.Result
的调用,这就是我在博客中描述的
要解决此问题,请将所有Wait
和Result
调用替换为Wait
。在我的任务中,我将其描述为“一路异步”。结果正是导致问题的原因。我试图从异步签名函数返回结果。现在它工作得很好。我将阅读您的博客文章了解更多信息,谢谢!