Delphi TComPort WriteAsync -


i trying send string through tcomport component asynchronously, sent synchronously. issue app blocked , wait until transmission over.

my code:

procedure tform1.button1click(sender: tobject); var   sss: string;   i: integer;   t: cardinal; begin sss:=''; := 0 100   begin     sss:= sss + '1';   end;   memo1.lines.add('str len - ' + inttostr(length(sss)));  if self.myport1.connected   begin     initasync(operation1);   try     self.myport1.writestrasync(sss,operation1);      t:= gettickcount;     self.myport1.waitforasync(operation1);      t:= gettickcount - t;       doneasync(operation1);   end;    memo1.lines.add('ΠΆ - ' + inttostr(t)); end; end; 

writing asynchronous. call of waitforasync after writing kills sense of asynchronous operation.

if need sure in completion of writing, make waitforasync before next writing operation (or before action requires writing completion).

in general - worth wait completion of overlapped operation in additional thread or use completion callback routine notification


Comments

Popular posts from this blog

javascript - WinJS appendTextAsync producing scheduler errors -

minify - Minimizing css files -

Sockets with kotlin -