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();