I am trying to send a string through TComPort component asynchronously, but everything is sent synchronously. The issue is that the app will be blocked and wait until the transmission is over.
My code:
procedure TForm1.Button1Click(Sender: TObject);
var
sss: string;
i: Integer;
t: cardinal;
begin
sss:='';
for i := 0 to 100 do
begin
sss:= sss + '1';
end;
memo1.Lines.Add('Str len - ' + IntToStr(Length(sss)));
if self.MyPort1.Connected then
begin
InitAsync(Operation1);
try
self.MyPort1.WriteStrAsync(sss,Operation1);
t:= GetTickCount;
self.MyPort1.WaitForAsync(Operation1);
t:= GetTickCount - t;
finally
DoneAsync(Operation1);
end;
memo1.Lines.Add('ΠΆ - ' + IntToStr(t));
end;
end;