Created
April 22, 2011 08:35
-
-
Save takekazuomi/936277 to your computer and use it in GitHub Desktop.
main loop
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
try { | |
if (concurrency == 1) { | |
foreach (var es in EntityGenerator<EntityOne>.Shift(source, batchSize)) { | |
body(es, null, monitor); | |
} | |
} else { | |
ParallelOptions options = new ParallelOptions(); | |
options.MaxDegreeOfParallelism = concurrency; | |
var result = Parallel.ForEach<IEnumerable<EntityOne>, ElapsedMonitor>( | |
EntityGenerator<EntityOne>.Shift(source, batchSize), | |
options, | |
() => new ElapsedMonitor(), | |
body, | |
(m) => { | |
lock (monitor) { | |
monitor.Merge(m); | |
} | |
}); | |
} | |
} catch (Exception e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment