Created
November 24, 2014 09:19
-
-
Save 0xorial/8b82594e8f2b96beae77 to your computer and use it in GitHub Desktop.
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
public class Parallel2 | |
{ | |
public delegate void ParallelForBodyDelegate(int i, int progress); | |
public static void For(int fromInclusive, int toExclusive, ParallelForBodyDelegate body) | |
{ | |
int counter = 0; | |
Parallel.For( | |
fromInclusive, | |
toExclusive, | |
i => | |
{ | |
int progress = Interlocked.Increment(ref counter); | |
body(i, progress); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment