On 23/10/17 20:00, Giuliano Colla via Lazarus wrote:
[snip]

I don't remember if I was hitting AV using Now(), likely I wasn't - 
but due to 'normal' Now() being not thread safe, I was getting inconsistent 
timing results, when I used Now() both in main thread and in the thread;

So with my application I ended up re-implementing Now() into ThreadNow :

var ThreadNowInUse :boolean = false; // unit global 'just' above the function

function TMyThread.ThreadNow: TDateTime;

var ASystemTime : TSYSTEMTIME;  // struct.inc, I'm under Windows

begin
  repeat
  until not ThreadNowInUse;  // 
  
  try
    ThreadNowInUse :=true;
    GetSystemTime(ASystemTime);
    Result := SystemTimeToDateTime(ASystemTime);
  finally
    ThreadNowInUse := false;
  end;

end;

Hope this helps

el es

-- 
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to