using System; using System.Diagnostics; using System.Threading; using Implab.Diagnostics; using System.Linq; using Xunit; namespace Implab.Test { using System.Threading.Tasks; using static Trace; public class UnitTest1 { [Fact] public async Task Test1() { var listener = new SimpleTraceListener(Console.Out); listener.TraceOutputOptions |= TraceOptions.ThreadId; var source = TraceSource; source.Switch.Level = SourceLevels.All; source.Listeners.Add(listener); using (LogicalOperation("Test1")){ await Task.Yield(); Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast().Select(x => x.ToString()))); await AsyncDummy(); Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast().Select(x => x.ToString()))); } } async Task AsyncDummy() { using(LogicalOperation("OuterDummy")) using(LogicalOperation("InnerDummy")) { Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast().Select(x => x.ToString()))); await Task.Delay(1); Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast().Select(x => x.ToString()))); } Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast().Select(x => x.ToString()))); } } }