-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParalelHelperActionBlock.cs
60 lines (51 loc) · 1.6 KB
/
ParalelHelperActionBlock.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Reflection;
// using System.Threading;
// using System.Threading.Tasks;
// using System.Threading.Tasks.Dataflow;
// namespace C__Örneklerim
// {
// class Program
// {
// static async Task Main()
// {
// var throwIfNegative = new ActionBlock<int>(n =>
// {
// Console.WriteLine("n = {0}", n);
// });
// throwIfNegative.Post(0);
// throwIfNegative.Post(2);
// throwIfNegative.Post(3);
// await ForAsync(0, 10, async (index) =>
// {
// System.Console.WriteLine(index);
// while (true)
// {
// }
// }, 2);
// System.Console.WriteLine("cıktık");
// Console.ReadLine();
// }
// public static Task ForAsync(
// long fromInclusive,
// long toExclusive,
// Func<long, Task> body,
// int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded
// )
// {
// var options = new ExecutionDataflowBlockOptions()
// {
// MaxDegreeOfParallelism = maxDegreeOfParallelism
// };
// var block = new ActionBlock<long>(body, options);
// for (long index = fromInclusive; index < toExclusive; ++index)
// {
// block.Post(index);
// }
// block.Complete();
// return block.Completion;
// }
// }
// }