我想創建一些嵌套文件夾對象即時通訊發送如果有父母身份證當我調試後,等待它的行爲就像打破它不遵循下一個代碼行我能做什麼我無法找到任何解決方案互聯網。異步方法doesnt繼續以下代碼
public class FileOperations
{
StorageFolder newFile,newFolder;
List<StorageFolder> folderList = new List<StorageFolder>();
public async void CreatingFiles(int cat, int par, string name)
{
StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
if (par == 0)
{
StorageFolder file = Windows.Storage.ApplicationData.Current.LocalFolder;
newFile = await file.CreateFolderAsync(name, CreationCollisionOption.ReplaceExisting);
folderList.Add(newFile);
}
else
{
for (int i = 1; i <= folderList.Count; i++)
if (par == i)
{
newFolder = await folderList[par - 1].CreateFolderAsync(name, CreationCollisionOption.ReplaceExisting);
folderList.Add(newFolder);
}
}
}
public Task InitializeAsync()
{
return InitializeOfflineFilesAsync();
}
private Task InitializeOfflineFilesAsync()
{
throw new NotImplementedException();
}
private async Task<StorageFolder> CF(string name, CreationCollisionOption replaceExisting, StorageFolder file)
{
return await file.CreateFolderAsync(name, replaceExisting);
}
}
問題是什麼?什麼不行?另外你的其他部分怎麼處理循環?它讓我想起[For-If-Antipattern](http://blogs.msdn.com/b/oldnewthing/archive/2011/12/27/10251210.aspx) –
而且你應該避免使用'async void'方法。它們幾乎完全存在於事件處理程序中。 'async Task'是與'void'同步方法的異步等效方法。 – Dirk
你打電話給這個怎麼樣?你有沒有在你的調用堆棧上有一個「Wait」或「Result」? –