VS C # Debug - Output window use

Output Window

As a debugging tool for debugging stage.

One usage:

You need to reference the namespace: System.Diagnostics;

Add Method: Trace.WriteLine (string message); message data is needed to fill the output

Application scenarios:

1. Non-console project, during the commissioning phase, you can easily use

2. When the program logic has become clear that there is no problem, but do not want to see the process variable value and output value by setting breakpoints. This time may be selected to visually display the output window.

For Liezi: Get the thread ID

 1         public MainWindow()
 2         {
 3             InitializeComponent();
 4             Trace.WriteLine($"Main Thread--{Thread.CurrentThread.ManagedThreadId}");
 5             var t = new Task(() => SayHello());
 6             Trace.WriteLine($"Main Start--{t.Id}");
 7             t.Start();
 8             t.Wait();
 9             Trace.WriteLine($"Main End--{t.Id}");
10         }
11 
12         public void SayHello()
13         {
14             Trace.WriteLine($"Task Start--{Thread.CurrentThread.ManagedThreadId}");
15             Thread.Sleep(1000);
16             Trace.WriteLine($"Task End--{Thread.CurrentThread.ManagedThreadId}");
17         }

 

Guess you like

Origin www.cnblogs.com/YourDirection/p/12498928.html