[fpc-devel] Threads not working in console application

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Dec 6 14:11:38 CET 2007


On 06/12/2007, Yury Sidorov <jura at cp-lab.com> wrote:
>
> The thread itself works, but not Synchronize() method.
> You need to call CheckSynchronize inside main loop.
>

Ah, thanks Yury!  That also means that having the main loop fire every
500ms (it was just a test for the console app), my timer cannot fire
it's events in less than 500ms (eg: timer.Interval := 200).

  while True do
  begin
    if FileExists('killme') then
      break;
    Sleep(500);
    CheckSynchronize;
    writeln('event loop');
  end;


As a test, I set the main loop's Sleep() to 10ms and the app didn't
even register in 'top' for CPU usage, so I guess it's ok to set
sleep() with such a small time?
Not that I intend to use the Timer interval for <500ms though.


I'll read up no CheckSyncronize to get a better understanding of this...


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list