N
narcisse
Unregistered / Unconfirmed
GUEST, unregistred user!
我是这样做的在两个定时器里分别作了这样的操作
timer1里监测主程序中idTCPCLIENT控件的连接状态若断了则将线程ClientThread 挂起suspend
timer2中监测若idTCPCLIENT是断开后又连上则将线程ClientThread 唤醒
可是在这里唤醒时线程的执行不正常,但我如果直接调用ClientThread.execute程序的执行就是正常的了这是怎么回事啊
timer1的事件
procedure Tmain_Form.Timer2Timer(Sender: TObject);
begin
try
self.IdTCPClient1.CheckForGracefulDisconnect()
except
on E: Exceptiondo
begin
self.lbx_msg.Items.Add('Tcp链路断开,请检查设置!');
if ClientHandleThread.Suspended = false then
begin
try
ClientHandleThread.Suspend;
showmessage('try to Suspend the thread');
except
on E:Exceptiondo
end
end;
end;
end;
end;
timer2的事件
if self.IdTCPClient1.Connected = true then
begin
if ClientHandleThread.Suspended = true then
begin
try
showmessage('try to resume');
ClientHandleThread.Execute;
except
on e:Exceptiondo
begin
main_Form.lbx_msg.Items.Add('The monitor thread can not be resumed!');
end;
end;
end;
帮帮看看阿
只有这么多分了大家帮忙看看阿
timer1里监测主程序中idTCPCLIENT控件的连接状态若断了则将线程ClientThread 挂起suspend
timer2中监测若idTCPCLIENT是断开后又连上则将线程ClientThread 唤醒
可是在这里唤醒时线程的执行不正常,但我如果直接调用ClientThread.execute程序的执行就是正常的了这是怎么回事啊
timer1的事件
procedure Tmain_Form.Timer2Timer(Sender: TObject);
begin
try
self.IdTCPClient1.CheckForGracefulDisconnect()
except
on E: Exceptiondo
begin
self.lbx_msg.Items.Add('Tcp链路断开,请检查设置!');
if ClientHandleThread.Suspended = false then
begin
try
ClientHandleThread.Suspend;
showmessage('try to Suspend the thread');
except
on E:Exceptiondo
end
end;
end;
end;
end;
timer2的事件
if self.IdTCPClient1.Connected = true then
begin
if ClientHandleThread.Suspended = true then
begin
try
showmessage('try to resume');
ClientHandleThread.Execute;
except
on e:Exceptiondo
begin
main_Form.lbx_msg.Items.Add('The monitor thread can not be resumed!');
end;
end;
end;
帮帮看看阿
只有这么多分了大家帮忙看看阿