Recent

Author Topic: LNet - TLTcp in a thread locks whole application.  (Read 220 times)

blankname

  • New member
  • *
  • Posts: 5
LNet - TLTcp in a thread locks whole application.
« on: August 10, 2020, 04:22:45 pm »
I hav some code I want to use in a plugin for external application. The thing is, when I use TThread (TServerHandlerThread), and put some infinite loop, then the application does not respond - only the code of the TServerHandlerThread thread works. Is there any way to make it work? The plugin will be used in X-Plane 11 simulator.
Code: Pascal  [Select][+][-]
  1. procedure TServerHandlerThread.Execute;
  2. begin
  3.   FCon := TLTcp.Create(nil);
  4.   FCon.OnError := @OnEr;
  5.   FCon.OnReceive := @OnRe;
  6.   FCon.OnDisconnect := @OnDs;
  7.   FCon.OnAccept := @OnAc;
  8.   FCon.Timeout := 100;
  9.   FCon.ReuseAddress := True;
  10.  
  11.   if FCon.Listen(30123) then begin
  12.     repeat
  13.       FCon.Callaction;
  14.       Sleep(100);
  15.     until Quit;
  16.   end;
  17.  
  18.   FCon.Free;
  19. end;

blankname

  • New member
  • *
  • Posts: 5
Re: LNet - TLTcp in a thread locks whole application.
« Reply #1 on: August 10, 2020, 04:24:08 pm »
The network code works partially - server sends and receives packets.

blankname

  • New member
  • *
  • Posts: 5
Re: LNet - TLTcp in a thread locks whole application.
« Reply #2 on: August 10, 2020, 04:38:00 pm »
Problem solved - I ran the thread with .Execute instead of .Start :)

cdbc

  • Sr. Member
  • ****
  • Posts: 255
    • http://www.cdbc.dk
Re: LNet - TLTcp in a thread locks whole application.
« Reply #3 on: August 11, 2020, 08:52:25 pm »
Uuuhhmmm, doesn't that mean, you're running in the main thread?!?
Just wondering...

edit: Oh, now i get it  %)
Regards Benny
« Last Edit: August 11, 2020, 08:55:01 pm by cdbc »
If it ain't broke, don't fix it ;)

 

TinyPortal © 2005-2018