diff MonoPlay/Program.cs @ 201:d7cd7a83189a v2

TraceLog tests
author cin
date Mon, 17 Oct 2016 00:36:36 +0300
parents d45bdf510514
children
line wrap: on
line diff
--- a/MonoPlay/Program.cs	Fri Oct 14 04:03:10 2016 +0300
+++ b/MonoPlay/Program.cs	Mon Oct 17 00:36:36 2016 +0300
@@ -1,11 +1,6 @@
-using System;
-using Implab;
-using System.Threading.Tasks;
-using Implab.Formats.JSON;
-using System.IO;
-using System.Text.Json;
-using System.Diagnostics;
+using Implab;
 using Implab.Parallels;
+using Implab.Diagnostics;
 using System.Threading;
 
 namespace MonoPlay {
@@ -16,27 +11,29 @@
             var pool = new WorkerPool(10);
 
             var listerner = new ConsoleTraceListener();
-            listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
-            Trace.Listeners.Add(listerner);
+            listerner.Subscribe<TraceEvent>();
 
-            Trace.CorrelationManager.StartLogicalOperation("Main");
+            TraceLog.StartLogicalOperation("Main");
+
 
             var d = pool.Invoke(() => {
-                Trace.CorrelationManager.StartLogicalOperation("Worker");
+                TraceLog.StartLogicalOperation("Worker");
                 Thread.Sleep(100);
-                Trace.TraceInformation("worker done");
-                Trace.CorrelationManager.StopLogicalOperation();
+                TraceLog.TraceInformation("worker done");
+                TraceLog.EndLogicalOperation();
             });
 
+            var op = TraceContext.Instance.CurrentOperation;
             ThreadPool.QueueUserWorkItem((o) => {
-                Trace.CorrelationManager.StartLogicalOperation("Thread");
+                TraceContext.Instance.EnterLogicalOperation(op, false);
+                TraceLog.StartLogicalOperation("Thread");
                 Thread.Sleep(100);
-                Trace.TraceInformation("thread done");
-                Trace.CorrelationManager.StopLogicalOperation();
+                TraceLog.TraceInformation("thread done");
+                TraceLog.EndLogicalOperation();
             });
 
-            Trace.TraceInformation("main done");
-            Trace.CorrelationManager.StopLogicalOperation();
+            TraceLog.TraceInformation("main done");
+            TraceLog.EndLogicalOperation();
 
             d.Join();