# HG changeset patch # User cin # Date 2016-10-16 21:36:36 # Node ID d7cd7a83189a5845096090aa0f211615f0415b20 # Parent 71e543dbe65a0db08f7a54bef962ce2a5902d888 TraceLog tests diff --git a/MonoPlay/Program.cs b/MonoPlay/Program.cs --- a/MonoPlay/Program.cs +++ b/MonoPlay/Program.cs @@ -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 @@ namespace MonoPlay { var pool = new WorkerPool(10); var listerner = new ConsoleTraceListener(); - listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack; - Trace.Listeners.Add(listerner); + listerner.Subscribe(); - 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();