93
|
1 using System;
|
|
2 using Implab;
|
151
|
3 using System.Threading.Tasks;
|
183
|
4 using Implab.Formats.JSON;
|
|
5 using System.IO;
|
|
6 using System.Text.Json;
|
194
|
7 using System.Diagnostics;
|
|
8 using Implab.Parallels;
|
|
9 using System.Threading;
|
93
|
10
|
|
11 namespace MonoPlay {
|
|
12 class MainClass {
|
145
|
13
|
|
14
|
93
|
15 public static void Main(string[] args) {
|
194
|
16 var pool = new WorkerPool(10);
|
150
|
17
|
194
|
18 var listerner = new ConsoleTraceListener();
|
|
19 listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
|
|
20 Trace.Listeners.Add(listerner);
|
|
21
|
|
22 Trace.CorrelationManager.StartLogicalOperation("Main");
|
93
|
23
|
194
|
24 var d = pool.Invoke(() => {
|
|
25 Trace.CorrelationManager.StartLogicalOperation("Worker");
|
|
26 Thread.Sleep(100);
|
|
27 Trace.TraceInformation("worker done");
|
|
28 Trace.CorrelationManager.StopLogicalOperation();
|
|
29 });
|
136
|
30
|
194
|
31 ThreadPool.QueueUserWorkItem((o) => {
|
|
32 Trace.CorrelationManager.StartLogicalOperation("Thread");
|
|
33 Thread.Sleep(100);
|
|
34 Trace.TraceInformation("thread done");
|
|
35 Trace.CorrelationManager.StopLogicalOperation();
|
|
36 });
|
150
|
37
|
194
|
38 Trace.TraceInformation("main done");
|
|
39 Trace.CorrelationManager.StopLogicalOperation();
|
|
40
|
|
41 d.Join();
|
|
42
|
183
|
43
|
|
44
|
145
|
45 }
|
136
|
46
|
93
|
47 }
|
|
48 }
|