201
|
1 using Implab;
|
194
|
2 using Implab.Parallels;
|
201
|
3 using Implab.Diagnostics;
|
194
|
4 using System.Threading;
|
93
|
5
|
|
6 namespace MonoPlay {
|
|
7 class MainClass {
|
145
|
8
|
|
9
|
93
|
10 public static void Main(string[] args) {
|
194
|
11 var pool = new WorkerPool(10);
|
150
|
12
|
194
|
13 var listerner = new ConsoleTraceListener();
|
201
|
14 listerner.Subscribe<TraceEvent>();
|
194
|
15
|
201
|
16 TraceLog.StartLogicalOperation("Main");
|
|
17
|
93
|
18
|
194
|
19 var d = pool.Invoke(() => {
|
201
|
20 TraceLog.StartLogicalOperation("Worker");
|
194
|
21 Thread.Sleep(100);
|
201
|
22 TraceLog.TraceInformation("worker done");
|
|
23 TraceLog.EndLogicalOperation();
|
194
|
24 });
|
136
|
25
|
201
|
26 var op = TraceContext.Instance.CurrentOperation;
|
194
|
27 ThreadPool.QueueUserWorkItem((o) => {
|
201
|
28 TraceContext.Instance.EnterLogicalOperation(op, false);
|
|
29 TraceLog.StartLogicalOperation("Thread");
|
194
|
30 Thread.Sleep(100);
|
201
|
31 TraceLog.TraceInformation("thread done");
|
|
32 TraceLog.EndLogicalOperation();
|
194
|
33 });
|
150
|
34
|
201
|
35 TraceLog.TraceInformation("main done");
|
|
36 TraceLog.EndLogicalOperation();
|
194
|
37
|
|
38 d.Join();
|
|
39
|
183
|
40
|
|
41
|
145
|
42 }
|
136
|
43
|
93
|
44 }
|
|
45 }
|