문제

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