.net 在 Visual Studio 中调试时如何查看我的应用程序线程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/164600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 10:13:00  来源:igfitidea点击:

How can I see my applications threads while debugging in Visual Studio?

.netvisual-studiovisual-studio-2008multithreadingdebugging

提问by George Mauer

I would like to see the threads currently active in my application while debugging it.

我想在调试时查看我的应用程序中当前处于活动状态的线程。

How can I do this using Visual Studio?

如何使用 Visual Studio 执行此操作?

回答by RichS

Yes, go to Debug->Windows->Threads

是的,去调试->Windows->线程

回答by Ferruccio

Debug | Windows | Threads

调试 | 窗户 | 线程

or

或者

Ctrl-Alt-H

Ctrl-Alt-H

回答by Bill

While RichS' answer is technically correct, the information displayed in that window is not as helpful if you have a number of thread in wait states or sleeping.

虽然 RichS 的回答在技术上是正确的,但如果您有多个线程处于等待状态或睡眠状态,则该窗口中显示的信息并没有那么有用。

I would recommend you make sure you name your threads for better visibility in the Thread window. Use the Thread.Name property to assign a meaningful name to your thread. You'll be glad you did.

我建议您确保为您的线程命名,以便在“线程”窗口中获得更好的可见性。使用 Thread.Name 属性为您的线程分配一个有意义的名称。你会很高兴你做到了。

回答by Gulzar Nazim

If you are using VS 2008, check this screencast on VS 2008 multi-threading improvements..

如果您使用的是 VS 2008,请查看有关VS 2008 多线程改进的此截屏视频。

回答by Gulzar Nazim

Also, give your threads names when you create them, it makes it easier to identify them in the threads tool window in visual studio.

此外,在创建线程时为其命名,这样可以更轻松地在 Visual Studio 的线程工具窗口中识别它们。

回答by Gulzar Nazim

I've been using Allinea's DDTLite plugin recently - drops into VS2008 (SP1) pretty well and gives a number of really really useful windows for managing multiple threads (stepping, breakpoints, ..) or even just seeing where threads are at the same time (a sort of tree like view of the stacks, it's really cool).

我最近一直在使用 Allinea 的 DDTLite 插件 - 很好地融入了 VS2008 (SP1) 并提供了许多非常有用的窗口来管理多个线程(步进、断点等),甚至只是同时查看线程的位置(一种像树一样的堆栈视图,真的很酷)。

回答by Iqra.

You can simply track the threads either through visual studio or just from task manager. In the case of VS- after debugging your application just navigate to debug from upper menu options then goto to windows and then threads. Debug->Windows->Thread. sometimes you might not get information from VS thread windows so go to task manager from desktop and navigate to thread column. refer the image below. Here you go

您可以通过 Visual Studio 或仅从任务管理器简单地跟踪线程。在 VS 的情况下,在调试应用程序后,只需从上方菜单选项导航到调试,然后转到窗口,然后转到线程。调试->Windows->线程。有时您可能无法从 VS 线程窗口获取信息,因此请从桌面转到任务管理器并导航到线程列。参考下图。 干得好