BTW. What's wrong with using TThread.WaitFor on a terminated, but net yet freed TThread ??
This works for me:
type
TMyThread = class(TThread)
private
protected
procedure Execute; override;
end;
procedure TMyThread.Execute;
begin
end;
//...
var
T: TMyThread;
begin
T := TMyThread.Create(false);
Sleep(2000);
T.Terminate;
T.WaitFor; // even though there is no Execute (or has finished) WaitFor should still work but passthrough
end;
So the original problem, where WaitFor is a problem when the thread has already terminated, but not freed, lies somewhere else.