GetTickCount lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- JimKueneman · 2012-12-20 01:55 I am using this in a thread: Result := LclIntf.GetTickCount which at the end of the day calls this: fpgettimeofday(@tp, nil);  and it is crashing the application.  Should this be thread safe? OSX Lion Thanks, Jim ---------------------------------------------------------------------- User137 · 2012-12-20 04:05 Does the variable "tp" belong to the thread, or is it public variable that many threads could send same time? ---------------------------------------------------------------------- Dibo · 2012-12-20 05:26 What kind of type is your Result? I had this same issue. GetTickCount return DWord and my variable was Integer. Make sure that you are using Dword ---------------------------------------------------------------------- JimKueneman · 2012-12-20 13:43 QuoteDoes the variable "tp" belong to the thread, or is it public variable that many threads could send same time? It is created and used within the thread function. QuoteWhat kind of type is your Result? I had this same issue. GetTickCount return DWord and my variable was Integer. Make sure that you are using Dword As seen below it is a DWord. Here is the real code. This is in a TThread class in an overridden Execute method. Code: [Select]procedure TComPortThread.Execute; var   List: TList;   ReceiveStr, SendStr: AnsiString;   Helper: TOpenLCBMessageHelper;   CompletedSendDatagram: TDatagramSend;   T: DWord;  // Time the execution of the thread loop begin   T := 0;   CompletedSendDatagram := nil;   Helper := TOpenLCBMessageHelper.Create;   Serial := TBlockSerial.Create;                           // Create the Serial object in the context of the thread   Serial.LinuxLock:=False;   Serial.RaiseExcept:=False;   Serial.Connect(Port);   try     if Serial.InstanceActive then     begin       Connected:=True;       Serial.Config(BaudRate, 8, 'N', 0, False, False);      // FTDI Driver uses no stop bits for non-standard baud rates.       while not Terminated do       begin         ThreadSwitch;             // Let main thread have some time         T := GetTickCount;           ... ---------------------------------------------------------------------- JimKueneman · 2012-12-20 13:59 Hold the phone.... I am using this to time the loop: I time the loop then store the delta T in property of the class.  I then have some debug code that writes this to a form (yes I know accessing a form from a thread is bad but this is only for testing).  If I don't write to the form it works fine.  If I do write to the form it crashes.  I don't understand why I am using other properties to update this form... I guess I see what is crashing, just need to see why.  It is not the call to GetTickCount directly. Jim