Skip to content

Instantly share code, notes, and snippets.

@mayuki
Created April 17, 2010 08:06
Show Gist options
  • Select an option

  • Save mayuki/369396 to your computer and use it in GitHub Desktop.

Select an option

Save mayuki/369396 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
foreach (var x in Enumerable.Range(0, 10))
{
var sum = 0;
Parallel.For(0, 50000, i =>
{
sum += i;
});
Console.WriteLine("Parallel.For: {0}", sum);
}
Console.WriteLine("AsParallel.Sum: {0}", Enumerable.Range(0, 50000).AsParallel().Sum());
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment