質問

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.

役に立ちましたか?

解決

Your observation is correct. OnStopped is triggered in the context of the worker thread. OnTerminated is triggered in the context of the main thread.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top