##// END OF EJS Templates
TraceLog tests
cin -
r201:d7cd7a83189a v2
parent child
Show More
@@ -1,48 +1,45
1 using System;
1 using Implab;
2 using Implab;
3 using System.Threading.Tasks;
4 using Implab.Formats.JSON;
5 using System.IO;
6 using System.Text.Json;
7 using System.Diagnostics;
8 using Implab.Parallels;
2 using Implab.Parallels;
3 using Implab.Diagnostics;
9 using System.Threading;
4 using System.Threading;
10
5
11 namespace MonoPlay {
6 namespace MonoPlay {
12 class MainClass {
7 class MainClass {
13
8
14
9
15 public static void Main(string[] args) {
10 public static void Main(string[] args) {
16 var pool = new WorkerPool(10);
11 var pool = new WorkerPool(10);
17
12
18 var listerner = new ConsoleTraceListener();
13 var listerner = new ConsoleTraceListener();
19 listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
14 listerner.Subscribe<TraceEvent>();
20 Trace.Listeners.Add(listerner);
21
15
22 Trace.CorrelationManager.StartLogicalOperation("Main");
16 TraceLog.StartLogicalOperation("Main");
17
23
18
24 var d = pool.Invoke(() => {
19 var d = pool.Invoke(() => {
25 Trace.CorrelationManager.StartLogicalOperation("Worker");
20 TraceLog.StartLogicalOperation("Worker");
26 Thread.Sleep(100);
21 Thread.Sleep(100);
27 Trace.TraceInformation("worker done");
22 TraceLog.TraceInformation("worker done");
28 Trace.CorrelationManager.StopLogicalOperation();
23 TraceLog.EndLogicalOperation();
29 });
24 });
30
25
26 var op = TraceContext.Instance.CurrentOperation;
31 ThreadPool.QueueUserWorkItem((o) => {
27 ThreadPool.QueueUserWorkItem((o) => {
32 Trace.CorrelationManager.StartLogicalOperation("Thread");
28 TraceContext.Instance.EnterLogicalOperation(op, false);
29 TraceLog.StartLogicalOperation("Thread");
33 Thread.Sleep(100);
30 Thread.Sleep(100);
34 Trace.TraceInformation("thread done");
31 TraceLog.TraceInformation("thread done");
35 Trace.CorrelationManager.StopLogicalOperation();
32 TraceLog.EndLogicalOperation();
36 });
33 });
37
34
38 Trace.TraceInformation("main done");
35 TraceLog.TraceInformation("main done");
39 Trace.CorrelationManager.StopLogicalOperation();
36 TraceLog.EndLogicalOperation();
40
37
41 d.Join();
38 d.Join();
42
39
43
40
44
41
45 }
42 }
46
43
47 }
44 }
48 }
45 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now