[Lazarus] custom thread reading file does not respond properly
andrea.mauri.75 at gmail.com
Wed Sep 6 16:59:32 CEST 2017
2017-09-06 16:26 GMT+02:00 el es via Lazarus <lazarus at lists.lazarus-ide.org>
> Can you try ThreadSwitch after Sleep ?
> while (not Terminated) do
> if eof(f) then
> ReadLn(f, newStatus);
> if NewStatus <> fStatusText then
> fStatusText := newStatus;
> ThreadSwitch; /// <<<<
> else // also you need to cover what happens in ANY OTHER outcome of
> any test, e.g.
> // because if NewStatus = fStatusText, you will IMMEDIATELY jump to
> the first instruction of the thread
> // so adding the ThreadSwitch at the very end of the loop, you give
> the rest of the application (the main thread) a chance to
> // actually do anything
> Thread.Execute will execute ALL THE TIME if you don't yield/threadswitch
> in some code path, and WILL saturate your CPU.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus