procedure MonitorFile(const AID: Integer; const AFileDate: TDateTime; const AFilename: String);
begin
TThread.CreateAnonymousThread(
procedure
var
Doc: TDocuments;
t: Extended;
begin
while (GetFileModifiedDate(AFilename) = AFileDate) or (Application.Terminated) do
begin
t := Now;
repeat
sleep(10);
until (now - t > 100) or Application.Terminated;
end;
if (GetFileModifiedDate(AFilename) <> AFileDate) then
begin
Doc := TDocuments.Create(Nil);
try
if Doc.Load(AID) then
begin
Doc.DocImage.LoadFromFile(AFilename);
Doc.Save(False);
end;
finally
Doc.Free;
end;
end;
end
);
end;
Any idea why this wouldn’t work? It runs fine in 11.3.
In Delphi 12, I can’t step into it and the thread doesn’t run at all as far as I can see.