static void Main(string[] args)
    {
        var listener = new TestTraceListener();

        Trace.Listeners.Add(listener);
        Trace.WriteLine("Test");
        listener.Dispose();
        Trace.WriteLine("After dispose");
    }