Method PushScope
PushScope(TraceCategory, ITraceBackend?)
Pushes a trace scope that enables the specified categories and optionally sets a backend. Returns an IDisposable that restores the previous state when disposed. This is thread-safe and works correctly with parallel tests.
public static IDisposable PushScope(TraceCategory categories, ITraceBackend? backend = null)
Parameters
categoriesTraceCategoryThe trace categories to enable.
backendITraceBackendOptional backend to use. If null, uses default backend selection.
Returns
- IDisposable
An IDisposable scope that restores previous tracing state.
Examples
using (Trace.PushScope (TraceCategory.Command | TraceCategory.Mouse))
{
// Command and Mouse tracing enabled in this scope
CheckBox checkbox = new () { Id = "test" };
checkbox.InvokeCommand (Command.Activate);
}
// Previous tracing state restored