Problem in working with async and await?
Posted
by
Vicky
on Programmers
See other posts from Programmers
or by Vicky
Published on 2014-06-05T11:20:14Z
Indexed on
2014/06/05
15:36 UTC
Read the original article
Hit count: 1302
I am trying to upload files to Azure Blob Storage and after successful upload adding the filename to a list for my further operation. When i am doing synchronous it works fine but when i am doing async the error occured. Error : Collection was modified; enumeration operation may not execute.
foreach(var file in files)
{
// .....
await blockBlob.UploadFromStreamAsync(fs);
listOfMovedLabelFiles.Add(fileName);
}
if (listOfMovedLabelFiles.Count > 0) // error point
{
// my code for further operation
}
Is there any way to wait till all the async operations get completed.
© Programmers or respective owner