Reputation: 3753
Really simple but important question concerning TIdThreadComponent
:
In which thread are OnTerminate
and OnStopped
executed - main thread or the worker thread?
Can I safely assume I am in main thread when I am in these events (and call VCL properties and methods)?
Update: I figured I might use debugger and after trying that, looks like OnStopped
is within worker thread and OnTerminate
is inside main thread. Additional benefit is that debugger can help with determining where other related functions for starting/stopping/controlling thread are executed and reduce possible bugs.
Upvotes: 2
Views: 1010
Reputation: 597016
Your observation is correct. OnStopped
is triggered in the context of the worker thread. OnTerminated
is triggered in the context of the main thread.
Upvotes: 7