Created
April 17, 2010 08:06
-
-
Save mayuki/369396 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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