[Lazarus] Weird object variables access - fpc issue?
giuliano.colla at fastwebnet.it
Mon Oct 23 22:50:49 CEST 2017
Il 23/10/2017 21:33, Sven Barth via Lazarus ha scritto:
> How do you pass the SendMessage() method to your thread? And how does
> the code look that calls it?
The SendMessage() method belongs to the main thread only, and is
supposed to execute only in the main thread context.
It fills up a buffer (TBuffer), and sets a SendLen value and an OkToSend
boolean to true.
The buffer and SendLen are written by the main thread and read from the
serial thread. OkToSend is set by the main thread and reset by the
TBuffer, SendLen and OkToSend are public variables not belonging to any
The code looks like that:
TBuffer[J] := Etx;
SendLen := J;
OKToSend := True;
if not SendCreated then begin
if Send.suspended then
The serial thread checks for OkToSend, sets it to false, and takes care
of sending the message and getting an answer. Once it's done it posts a
message for the main thread and suspends itself.
SendMessage() isn't invoked any more until the serial thread has managed
to send the message, and to receive an answer, or the communication has
More information about the Lazarus