in a socket connection between client-server, i'm receiving informations about remote pc in a thread (in a loop) and a other specific info in another thread.
My problem is because when second thread is created the first is stopped immediately, but info that i want receive using second thread is necessary a loop as show below on code.
So, how can execute two thread simultaneously without stop some thread?
// Entry point of first thread
procedure TSock_Thread2.Execute;
var
s: String;
begin
inherited;
while not Terminated and Socket.Connected do
begin
if Socket.ReceiveLength > 0 then
begin
s := Socket.ReceiveText;
if Pos('<|CUR|>', s)>0 then begin
TSTMouse := TSock_Thread5.Create(Socket);
TSTMouse.Resume;
Socket.SendText('<|GETCURSORICON|>'); // after this line, TSock_Thread2 stop your execution
end;
end;
end;
// Entry point of second Thread
procedure TSock_Thread5.Execute;
var
s, Ponteiro: string;
begin
inherited;
while not Terminated and Socket.Connected do
begin
if Socket.ReceiveLength > 0 then
begin
s := Socket.ReceiveText;
if Pos('<|MOUSEICON|>', s) > 0 then // receiving mouse icon here
begin
Delete(s, 1, Pos('<|MOUSEICON|>', s) + 12);
Ponteiro := Copy(s, 1, Pos('<|>', s) - 1);
if Ponteiro <> '' then
(Form1.LV1.Selected.SubItems.Objects[2] as TForm2).lblPoint.Caption := Ponteiro;
Sleep(100);
Socket.SendText('<|GETCURSORICON|>'); // request cursor icon again
end;
end;
end;
end;