Skip to content

Instantly share code, notes, and snippets.

@0xorial
Created November 24, 2014 09:19
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 0xorial/8b82594e8f2b96beae77 to your computer and use it in GitHub Desktop.
Save 0xorial/8b82594e8f2b96beae77 to your computer and use it in GitHub Desktop.
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