i wrote a Thread.descendent class and in the execute method i put a a infinite loop to listen a com event, is considered a bad Threading practice use a infinite loop to do this ? the applications works fine , does not freeze and is allways responsive, i just answer because i want use the best method to threading.
procedure TMyThread.Execute;
begin
while True and not Terminated do
begin
AResult:= FListener.GetResult(Param1,Param2,5000);
if not VarIsNull(AResult) then
Synchronize(Process);
end;
end;
No, they're not bad, they're actually useful. It depends whether you left some part of the code that eats up memory as the infinite loop proceeds. Infinite loops are used at almost everything: video games, networking, machine learning, etc.
Infinite While Loop in Python Infinite while loop refers to a while loop where the while condition never becomes false. When a condition never becomes false, the program enters the loop and keeps repeating that same block of code over and over again, and the loop never ends.
The compiler transforms this into:
while not Terminated do
When written out this way I'm sure you'll agree it looks perfectly natural. This is a very common idiom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With