多线程编程中对VCL的锁定问题,望高手指教!(100分)

  • 主题发起人 主题发起人 xiaong
  • 开始时间 开始时间
X

xiaong

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
var
item:TListItem;
strIp:string;
aDate,aTime:TDateTime;
aDateTime:string;
nIndex:integer;
begin
strIp:=AThread.Connection.Socket.Binding.PeerIP;
//ShowMessage(strIp);
listView1.Canvas.Lock;
try
nIndex:=SeekListViewByIp(strIp);
if nIndex=-1 then
begin
item:=listView1.Items.Add;
item.Caption:=strIp;
aTime:=Time();
aDate:=Date();
aDateTime:=DateToStr(aDate)+' '+TimeToStr(aTime);
item.SubItems.Add(aDateTime);
item.SubItems.Add(aDateTime);
end;
finally
listView1.Canvas.Unlock;
end;
end;

当运行至item.caption:=strIP时,程序停止响应,搞不明白是怎么回事?
 
后退
顶部