Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What 4 threads are running under an empty new VCL forms application? [duplicate]

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.

enter image description here

like image 728
Jerry Dodge Avatar asked Jul 02 '12 02:07

Jerry Dodge


2 Answers

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.

enter image description here

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.
like image 126
RRUZ Avatar answered Nov 08 '22 20:11

RRUZ


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.

like image 31
pani Avatar answered Nov 08 '22 19:11

pani