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