-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimple.cs
More file actions
36 lines (32 loc) · 1.05 KB
/
Copy pathSimple.cs
File metadata and controls
36 lines (32 loc) · 1.05 KB
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
using System;
using System.Threading;
using System.Threading.Tasks.Dataflow;
namespace dataflow
{
public static class Simple
{
public static void Run()
{
void Do(int i)
{
Console.WriteLine("received {0}", i);
throw new Exception("oops!");
Thread.Sleep(2000);
}
var action = new ActionBlock<int>(Do, new ExecutionDataflowBlockOptions
{
BoundedCapacity = 1,
MaxDegreeOfParallelism = 1,
});
//Console.WriteLine("sending 1");
var res1 = action.Post(1);
Console.WriteLine("sent 1, result {0}", res1);
//Console.WriteLine("sending 2");
var res2 = action.Post(2);
Console.WriteLine("sent 2, result {0}", res2);
//Console.WriteLine("sending 3");
var res3 = action.Post(3);
Console.WriteLine("sent 3, result {0}", res3);
}
}
}