Jump to content

Tip Of The Day, Parallel Programming In C#


Recommended Posts

Posted

Hi guys, like to share a small tip which most of u might know.
The below code took me 16 seconds to execute. I am using 2.8-Ghz dual core 64 bit processor with 4 GB of RAM.
for (int i = 2; i < 20; i++)
{
var result = SumRootN(i);
Console.WriteLine("root {0} : {1} ", i, result);
}
Instead of a regular for loop I used Parallel.For method and now the execution time got decreased from 16 to 5 seconds

Parallel.For(2, 20, (i) =>
{
var result = SumRootN(i);
Console.WriteLine("root {0} : {1} ", i, result);
});

To view the complete functionality please visit my blog

http://vsaditya.blogspot.com/2014/04/parallel-programming.html

Posted

Framework 4.0 ninchi start ayindi kada ee Parallel class. anthakamundhu lekuknde.

  • Upvote 1
Posted

gp

.net starting lo simple gaa undedhi.. events, delegates, parallel prog. hard ga unnayi..  but important concepts hmmm

  • Upvote 1
Posted

....GP....

 

 

Keep posting new stuff...

  • Upvote 1
Posted

I am not sure if Java has this but u can achieve the above by using threads in Java

×
×
  • Create New...