public void TraceParallelEnvironmentReferenceTest() { Trace expected = TraceManager.BeginTrace(); Trace actual = null; var task = new TraceEnabledTask(() => actual = TraceManager.Trace); task.Start(); task.Wait(); TraceManager.EndTrace(); Assert.AreSame(expected, actual); }
public void TraceParallelEnvironmentContextTest() { var mainEvent = new AutoResetEvent(false); var taskEvent = new AutoResetEvent(false); Trace expected = TraceManager.BeginTrace(); var task = new TraceEnabledTask (() => { taskEvent.WaitOne(); TraceManager.Trace.BeginEntry("task root entry", pt.sapo.gis.trace.configuration.severityType.INFO); mainEvent.Set(); taskEvent.WaitOne(); TraceManager.Trace.BeginEntry("task child entry", pt.sapo.gis.trace.configuration.severityType.WARN); mainEvent.Set(); taskEvent.WaitOne(); TraceManager.Trace.EndEntry(); mainEvent.Set(); taskEvent.WaitOne(); TraceManager.Trace.EndEntry(); mainEvent.Set(); }); task.Start(); TraceManager.Trace.BeginEntry("main root entry", pt.sapo.gis.trace.configuration.severityType.INFO); taskEvent.Set(); mainEvent.WaitOne(); TraceManager.Trace.BeginEntry("main child entry", pt.sapo.gis.trace.configuration.severityType.WARN); taskEvent.Set(); mainEvent.WaitOne(); TraceManager.Trace.EndEntry(); taskEvent.Set(); mainEvent.WaitOne(); TraceManager.Trace.EndEntry(); taskEvent.Set(); mainEvent.WaitOne(); task.Wait(); TraceManager.EndTrace(); }