Created
January 13, 2018 17:47
-
-
Save arman-hpp/7ba44364a64d9094027bdeb7ee0b3516 to your computer and use it in GitHub Desktop.
Parallel.ForEach Progress
This file contains 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
SynchronizationContext ctx = SynchronizationContext.Current; | |
int count = 0; | |
Parallel.ForEach(collection, (item) => | |
{ | |
ComputeYourStuff(item); | |
Interlocked.Increment(ref count); | |
ctx.Post(d => { progressBar.Value = count; }, null); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment