W
wang_cai1
Unregistered / Unconfirmed
GUEST, unregistred user!
constructor QueryThread.create(ww: string);
begin
CoInitialize(nil);
try
inherited Create(true);
con := TADOConnection.Create(nil);
with condo
begin
LoginPrompt := False;
ConnectionString := ww;
// con.Connected := true;
end;
udp_c := TIdUDPClient.Create(nil);
sp_info := TADOStoredProc.Create(nil);
with sp_infodo
begin
Connection := con;
ProcedureName := 'get_targer_user;1';
CursorLocation := clUseServer;
end;
finally
CoUnInitialize;
end;
self.FreeOnTerminate := False;
end;
destructor QueryThread.Destroy;
begin
con.Free;
sp_info.Free;
CoUnInitialize;
inherited Destroy;
end;
procedure QueryThread.Execute;
begin
try
FillChar(R_msg, sizeof(R_msg), #0);
Tdata.Read(R_msg, sizeof(R_msg));
except
Exit;
end;
rpl := '';
C_Acc := R_msg.Name;
ww_ip := BBinding.PeerIP;
ww_port := BBinding.PeerPort;
if R_msg.Mtype = info then
begin
con.Connected := True;
p_info := R_msg.Info;
p_name := R_msg.Oper;
sp_info.Prepared := True;
sp_info.Parameters.Clear;
sp_info.Parameters.CreateParameter('@MSISDNP', ftFloat, pdInput, 0, StrToFloat(p_info));
sp_info.Parameters.CreateParameter('@IPADDR', ftstring, pdInput, 15, ww_ip);
sp_info.Parameters.CreateParameter('@RESULT', ftstring, pdOutput, 200, '');
try
sp_info.ExecProc;
rpl := sp_info.Parameters.ParamValues['@result'];
rpl_content := rpl;
udp_c.Send(ww_ip, ww_port, rpl_content);
Synchronize(send);
sp_info.Close;
con.Connected := False;
except
Exit;
end;
Self.Suspend;
while not Self.Suspendeddo
begin
Application.ProcessMessages;
end;
Exit;
end;
end;
procedure TServerF.Server1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var i: Integer;
begin
for i := 1 to 5do
begin
Application.ProcessMessages;
if query.Suspended then
//接收数据后,检测是否有挂起的线程
begin
query.Tdata := AData;
query.BBinding := ABinding;
Label3.Caption := IntToStr(i);
query.Resume;
Break;
end;
end;
end;
当UDP接收到数据后,i值不断增加,检测不到挂起的线程,i=5后线程将不工作,不知道怎么回事,请各位帮忙看一下
begin
CoInitialize(nil);
try
inherited Create(true);
con := TADOConnection.Create(nil);
with condo
begin
LoginPrompt := False;
ConnectionString := ww;
// con.Connected := true;
end;
udp_c := TIdUDPClient.Create(nil);
sp_info := TADOStoredProc.Create(nil);
with sp_infodo
begin
Connection := con;
ProcedureName := 'get_targer_user;1';
CursorLocation := clUseServer;
end;
finally
CoUnInitialize;
end;
self.FreeOnTerminate := False;
end;
destructor QueryThread.Destroy;
begin
con.Free;
sp_info.Free;
CoUnInitialize;
inherited Destroy;
end;
procedure QueryThread.Execute;
begin
try
FillChar(R_msg, sizeof(R_msg), #0);
Tdata.Read(R_msg, sizeof(R_msg));
except
Exit;
end;
rpl := '';
C_Acc := R_msg.Name;
ww_ip := BBinding.PeerIP;
ww_port := BBinding.PeerPort;
if R_msg.Mtype = info then
begin
con.Connected := True;
p_info := R_msg.Info;
p_name := R_msg.Oper;
sp_info.Prepared := True;
sp_info.Parameters.Clear;
sp_info.Parameters.CreateParameter('@MSISDNP', ftFloat, pdInput, 0, StrToFloat(p_info));
sp_info.Parameters.CreateParameter('@IPADDR', ftstring, pdInput, 15, ww_ip);
sp_info.Parameters.CreateParameter('@RESULT', ftstring, pdOutput, 200, '');
try
sp_info.ExecProc;
rpl := sp_info.Parameters.ParamValues['@result'];
rpl_content := rpl;
udp_c.Send(ww_ip, ww_port, rpl_content);
Synchronize(send);
sp_info.Close;
con.Connected := False;
except
Exit;
end;
Self.Suspend;
while not Self.Suspendeddo
begin
Application.ProcessMessages;
end;
Exit;
end;
end;
procedure TServerF.Server1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var i: Integer;
begin
for i := 1 to 5do
begin
Application.ProcessMessages;
if query.Suspended then
//接收数据后,检测是否有挂起的线程
begin
query.Tdata := AData;
query.BBinding := ABinding;
Label3.Caption := IntToStr(i);
query.Resume;
Break;
end;
end;
end;
当UDP接收到数据后,i值不断增加,检测不到挂起的线程,i=5后线程将不工作,不知道怎么回事,请各位帮忙看一下