当前位置: 动力学知识库 > 问答 > 编程问答 >

multithreading - What 4 threads are running under an empty new VCL forms application?

问题描述:

Possible Duplicate:

What are the other threads in a default VCL application, and can they be named by purpose?

When running a new empty VCL Forms Application in Delphi XE2 (32bit), I see 4 threads running in the Task Manager for this app. Obviously any app requires at least 1 thread, but in this case, what are the other 3 threads? I'd like to have a better understanding of what threads any VCL forms application runs by default. I thought possibly it had to be the fact that I was running in debug mode from RAD Studio, so I launched the EXE its self, and it also had 4 threads running. I also tried compiling under "release" config (thus disabling compiling debug info) and there are still 4 threads.

网友答案:

To determine the source of the threads, you can inspect the start address of the threads using a tool like process explorer or process hacker.

In this case for example you can see

  • ntdll.dll!TpCallbackIndependent+0x????? which is part of the Windows threadpool API.
  • ntdll.dll!RtlMoveMemory+0x????? is a call to the RtlMoveMemory WinAPi function.
  • Project??.Exe+0x????? Main thread of the App.
网友答案:

On my computer all the other threads than the main thread are created because the application's window registered to receive session change notifications with Wtsapi32.WTSRegisterSessionNotification API. You can see the implementation inside Vcl.Forms -> TApplication.CreateHandle procedure. It must have to do with how the application work/looks when you logged through Terminal Services/Remote Desktop. Some other threads could possible exist because some other program/s loaded code into your executable.

分享给朋友:
您可能感兴趣的文章:
随机阅读: