在Visual Studio 2008中调试多线程C# - C ++ / CLI - C ++解决方案:这些线程是什么? [英] Debugging a Multithreaded C# - C++/CLI - C++ Solution in Visual Studio 2008: What are these threads?

查看:474
本文介绍了在Visual Studio 2008中调试多线程C# - C ++ / CLI - C ++解决方案:这些线程是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个包含三级代码的项目。最低层是与硬件交互的本机C ++。这是成熟,稳定和经过良好测试。中级代码是C ++ / CLI,它与包含UI元素的顶级C#代码和一些附加功能进行交互。这个C#代码是不完整的,并且正在开发中:它经常崩溃,不符合目的。我的任务是调试它并完成它。



我使用VS 2008来逐步通过多线程代码来了解从该项目开始的位置。简单的问题:在Threads窗口中,我有两个命名线程:一个工作线程,它与一些底层硬件(即C ++代码)和用户界面线程进行通信。



然而,逐步完成代码,有很多Worker Threads没有名称,没有与它们相关联的调用堆栈,看起来似乎是随机的。它们在调试位置工具栏中没有条目,并且当选择显示源中的线程时,代码中似乎不可见。



他们是什么,我应该关心他们?它们似乎不是来自本地代码(因为它使用Boost进行线程化,从调用堆栈中可以清楚)。冻结他们或改变他们的优先级似乎没有任何效果。



我没有调试这个复杂性的多线程代码,所以任何建议都非常感谢!

解决方案

除了应用程序的线程之外,还有一些.NET应用程序。运行时使用专用线程来运行finalizer。由于指出,您可能会看到线程池线程。调试器也启动一个线程。如果您使用的是vshost,您将获得相当的一点额外的线程


I've inherited a project consisting of three levels of code. The lowest layer is native C++ that interacts with hardware. This is mature, stable and well-tested. The intermediate level code is C++/CLI, which interacts with top-level C# code that contains the UI elements and some additional functionality. This C# code is incomplete and was rushed in development: it crashes frequently and is not fit for purpose. My task is debug it and complete it.

I'm using VS 2008 to step through the multithreaded code to understand where to start with this project. Simple question: in the Threads window, I have two named threads: a Worker thread which communicates with some of the underlying hardware (i.e. the C++ code) and a User Interface thread.

Stepping through the code, however, there are quite a few Worker Threads that have no name and no call stack associated with them, which appear seemingly randomly. They don't have an entry in the Debug Location toolbar, and they don't appear to be visible in the code when 'Show threads in source' is selected.

What are they, and should I be concerned about them? They don't appear to be from the native code (as it uses Boost for threading and this is clear from the call stack). Freezing them or changing their priority seems to have no effect.

I've not debugged multi-threaded code of this complexity before so any advice much appreciated!

解决方案

In addition to the threads of your application there are a few others in a .NET application. The runtime uses a dedicated thread for running finalizers. As driis points out you may see thread pool threads as well. The debugger also starts a thread as well. If you're using the vshost you'll get quite a bit of overhead an additional threads.

这篇关于在Visual Studio 2008中调试多线程C# - C ++ / CLI - C ++解决方案:这些线程是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆