Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created June 3, 2018 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/9941be3f29b1fd41e5ab01d84d57ae66 to your computer and use it in GitHub Desktop.
Save NMZivkovic/9941be3f29b1fd41e5ab01d84d57ae66 to your computer and use it in GitHub Desktop.
async Task<int> UploadFilesAsync(List<File> listOfFiles, IProgress<int> progress)
{
int processCount = await Task.Run<int>(() =>
{
int tempCount = 0;
foreach (var file in listOfFiles)
{
//await the uploading logic here
int processed = await UploadFileAsync(file);
if (progress != null)
{
progress.Report(tempCount);
}
tempCount++;
}
return tempCount;
});
return processCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment