Reputation: 2736
I expected that by using Loop
property I can define if OnRun
event method is repeatedly executed, but regardless, it is always repeating until I call method Terminate
. Am I missing the point of this property or there is a bug in the IdThreadComponent component?
Upvotes: 0
Views: 972
Reputation: 597036
Internally, TIdThreadComponent
runs a TIdThread
, which actually has 2 loops in its Execute()
method:
An outer loop is a usual while not Terminated
loop.
Inside of that loop, it first checks if the Stop()
method has been called to suspend the thread, and then (after waking up if stopped) it checks Loop
to determine whether the Run()
method should be called one time or in a loop.
So, the Loop
property does not really have much effect in TIdThreadComponent
, because of the outer while not Terminated
loop. All it really does is helps you control how often the thread checks its Stopped
property to know when go to sleep, if ever.
The Loop
logic is primarily meant for use by TIdTCPServer
instead, to control whether its OnExecute
event is fired one time or repeatedly for each accepted client connection.
Upvotes: 2