简体   繁体   中英

Is it possible to trap thread start and end events?

I've inherited a reasonably large visual studio WinForms project in C# and VB.Net

While I'm working with it, I get messages in the Debug window like this:

The thread '<No Name>' (0x1194) has exited with code 0 (0x0).
The thread '<No Name>' (0x664) has exited with code 0 (0x0).
The thread '<No Name>' (0x14b0) has exited with code 0 (0x0).

In an effort to better understand the software, I'm curious to investigate what these threads are. Are there any tools I can use or or debugging options I can turn on that will allow me to break when new threads are created / terminated?

Note: I've stuck breakpoints on all the "... = new Thread" and "... .RunWorkerAsync()" code I can find and it's none of them.

我知道这不是您问题的确切答案,但是这里有一些相关信息已发布到另一个问题: 在Visual Studio调试器中中断线程的创建

In the Thread class there is a name property that you can set. When you change it, the "No Name" text in the output will be replaced with what you set there. This will make it easier for you to see what is going on.

Thread MyThread = new Thread(...);
MyThread.Name = "MyName"; //Can only be set once.
MyThread.Start(....);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM