c# - performance of parallel for loop -
this question has answer here:
- limit number of parallel threads in c# 5 answers
i need set number of processor's threads parallel "for-loop". want work 3 threads of 8 (4-cores processor) ..... i'm using 8 threads.
system.threading.tasks.parallel.for(0, exponentstring.length, (i, loopstate) => { int y = my_function (a, exponent[i], modulo); string str = y.tostring(); if (str == numbers[0]) { loopstop = 1; loopstate.stop(); } });
thanks ideas.
there overload takes paralleloptions
object:
var options = new paralleloptions(); options.maxdegreeofparallelism = 3; parallel.for(0, exponentstring.length, options, (i, loopstate) => { ... });
Comments
Post a Comment