默认VCL应用程序中的其他线程是什么,它们可以按目的命名? [英] What are the other threads in a default VCL application, and can they be named by purpose?

查看:160
本文介绍了默认VCL应用程序中的其他线程是什么,它们可以按目的命名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您创建一个基本的VCL应用程序并执行它,则有几个线程运行。每个线程是什么以及可以命名的,以便更容易调试多线程应用程序?

If you create a basic VCL application and execute it, there are a few threads running. What are each of the threads for and can they be named to make it easier to debug multi-threaded applications?

我尝试命名我的所有子线程,并且在查看线程状态调试窗口时清楚了解每个子线程正在做什么,这在调试中非常有用。 (如果没有命名,这将是一个提示,跟踪它,并命名。)

I try to name all my child threads and it would be useful in debugging to have a clear idea of what each child thread is doing when viewing the Thread Status debug window. (And if one isn't named it would be a hint to track it down and get it named.)

推荐答案

在XE2中的vanilla 32位VCL应用程序,运行在64位Windows 7上有3个线程。主线和两个额外。通过调用 WTSRegisterSessionNotification TApplication.CreateHandle 中创建两个额外的线程。如果您要命名,那么您可以枚举过程中的线程>并调用 NameThreadForDebugging

A plain vanilla 32 bit VCL app in XE2, running on 64 bit Windows 7 has 3 threads. The main thread and two extras. The two extra threads are created in TApplication.CreateHandle by a call to WTSRegisterSessionNotification. If you want to name them then you can enumerate the threads in the process and call NameThreadForDebugging.

根据我的经验,很难跟踪你的应用程序中的所有线程。一旦你的应用程序变得适度复杂,那么可能会有很多线程来来往往。我个人认为我没有命名为别人的责任!

In my experience, it's very hard to keep track of all the threads in your app. As soon as your app becomes moderately complex then there are liable to be plenty of threads coming and going. I personally view the ones that I have not named as being somebody else's responsibility!

这篇关于默认VCL应用程序中的其他线程是什么,它们可以按目的命名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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