Replies: 3 comments
-
Another way to do that is to use Parallel.For(0, 10, (i)=>dosomething(i)); to: Parallel.For(0, 10, new ParallelOptions { MaxDegreeOfParallelism = 1 }, (i)=>dosomething(i)); More importantly:
|
Beta Was this translation helpful? Give feedback.
-
I don't see enough bang-for-buck here. The typing and performance savings of a keyword over calling |
Beta Was this translation helpful? Give feedback.
-
I'm with @svick on this one. There is no other construct in C# that allows for "forking" execution in the middle of a method. Having multiple threads automatically start executing within the loop body would be unexpected. With lambdas/delegates there is an expected separation as to if/when/how the delegate will be invoked. Constructs like Then there's the argument that if it can be managed easily enough with a library method that there's really no need for a language modification anyway. The syntax for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Could use the parallelfor parallelforeach as key words such as for foreach to do circile parallelly.
Current the function style is so ugly.
for (int i =0; i <10; i++)
dosomething(i);
int
Parallel.For(0,10,
(i)=>dosomething(i));
change to
parallelfor( int i =0; i <10; i++)
dosomething(i);
and its easy to change to single threat and debug.
Beta Was this translation helpful? Give feedback.
All reactions