<div dir="ltr">2017-09-06 16:26 GMT+02:00 el es via Lazarus <span dir="ltr"><<a href="mailto:lazarus@lists.lazarus-ide.org" target="_blank">lazarus@lists.lazarus-ide.org</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
</div></div>Can you try ThreadSwitch after Sleep ?<br>
<br>
while (not Terminated) do<br>
begin<br>
if eof(f) then<br>
reset(f);<br>
ReadLn(f, newStatus);<br>
if NewStatus <> fStatusText then<br>
begin<br>
fStatusText := newStatus;<br>
//Queue(@ShowStatus);<br>
Synchronize(@Showstatus);<br>
Sleep(5);<br>
ThreadSwitch; /// <<<<<br>
end<br>
else // also you need to cover what happens in ANY OTHER outcome of any test, e.g.<br>
ThreadSwitch;<br>
// because if NewStatus = fStatusText, you will IMMEDIATELY jump to the first instruction of the thread<br>
// so adding the ThreadSwitch at the very end of the loop, you give the rest of the application (the main thread) a chance to<br>
// actually do anything<br>
end;<br>
<br>
Thread.Execute will execute ALL THE TIME if you don't yield/threadswitch in some code path, and WILL saturate your CPU.<br><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Actually using sleep(1) I can interact with my application. ThreadSwitch does not introduce any change. If I use sleep(1) it works, if I don't use it but I use Yield or ThreadSwitch I cannot interact with my application. </div></div></div></div>