-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskParellel.cs
More file actions
33 lines (25 loc) · 922 Bytes
/
TaskParellel.cs
File metadata and controls
33 lines (25 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Threading.Tasks;
namespace TaskParellel
{
class Porgram
{
static void MainTest()
{
Console.WriteLine("2018-4-22");
Parallel.For(0, 15, i =>
Console.WriteLine("The square of {0} is {1}", i, i * i));
const int MaxValues = 50;
int[] square = new int[MaxValues];
Parallel.For(0, MaxValues, i => square[i] = i * i);
foreach(var i in square)
Console.Write(i + " ");
Console.WriteLine();
string[] squares = new string[]
{"We", "hold", "these", "truths", "to", "be", "self-evident",
"that", "all", "men", "are", "created", "equal"};
Parallel.ForEach(squares,
i=> Console.WriteLine(string.Format("{0} has {1} letters",i, i.Length)));
}
}
}