Table of Contents

Method PushScope

Namespace
Terminal.Gui.Tracing
Assembly
Terminal.Gui.dll

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

categories TraceCategory

The trace categories to enable.

backend ITraceBackend

Optional 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