Created
May 26, 2016 19:52
-
-
Save mantzas/ae8012f45e11cee367ed5986851f643e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<int> ProcessMessagesAsync(List<string> messages, IProgress<int> progress) | |
{ | |
int totalCount = messages.Count; | |
int processCount = await Task.Run<int>(() => | |
{ | |
int tempCount = 0; | |
foreach (var message in messages) | |
{ | |
Console.WriteLine(message); | |
if (progress != null) | |
{ | |
progress.Report((tempCount * 100 / totalCount)); | |
} | |
tempCount++; | |
} | |
return tempCount; | |
}); | |
return processCount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment