[fpc-pascal] TThread.WaitFor not returning?
Luca Olivetti
luca at ventoso.org
Tue Sep 16 17:49:04 CEST 2008
En/na Graeme Geldenhuys ha escrit:
>
> procedure TtiLogToCacheAbs.Terminate;
> begin
> writeln('>> TtiLogToCacheAbs.Terminate');
> FThrdLog.Terminate;
> writeln(' called .Terminate() and now calling .WaitFor()');
> FThrdLog.WaitFor;
> writeln('<< TtiLogToCacheAbs.Terminate');
> end;
>
> Any ideas?
Do you call synchronize inside the thread?
Anyway, I don't usually call WaitFor (I've had many problems with it), I
set a flag in the thread and I loop sleeping (or calling
checksynchronize if the thread uses synchronize) until it's true, eg:
procedure TMyThread.execute;
begin
while not terminated do
begin
....
end;
finished:=true;
end;
MyThread.Terminate;
while not MyThread.Finished do sleep(100);
or
while not MyThread.Finished do CheckSynchronize(100);
Bye
--
Luca
More information about the fpc-pascal
mailing list