internal static void End(string name) { if (TraceMonitoredScope) { MonitoredScope monitoredScope = instance; if (!string.Equals(monitoredScope.stack.Peek().Key, name, StringComparison.InvariantCulture)) { throw new Exception("MonitoredScope cannot be ended because the start and end scope names do not match!"); } monitoredScope.Dispose(); } }
internal static MonitoredScope New(string name) { if (!TraceMonitoredScope) { return(dummyInstance); } MonitoredScope monitoredScope = instance; if (monitoredScope == null) { monitoredScope = (instance = new MonitoredScope()); } monitoredScope.Start(name); return(monitoredScope); }