一个通信线程处理程序,在主界面有一个刷新按钮 启动一个timer 来刷新 Listview(用Virtual方法来根系) 来显示 来源IP 
程序一开始都没有什么问题,但是运行一段时间 (有时候1天,有时候2天),然后点击下刷新按钮 主界面 假死 无响应了,
但是通信线程还是正常的处理。弄了半个月了还是找不原因。所有实在没法子了,发帖来求助

解决方案 »

  1.   

    ListView里面要显示的数据太多导致的。
    1.优化代码
    2.大循环处理item的前后加上        ListView1.Items.BeginUpdate;
    //大量数据处理部分
           ListView1.Items.EndUpdate
      

  2.   

    在TWebModule1.ListView1Data(Sender: TObject; Item: TListItem)里进行数据更新的,
    数据量不大,几百条的样子
      

  3.   

    哪更新的没关系,找到相应循环add、delete等之类的代码,用那2句框起来就行
      

  4.   

    Virtual Listview 自己加载数据的 所有没有循环
      

  5.   

    在Listview 的ondata事件里:  
    if not Assigned(Users) then
        Exit;
      UserSocket := users.ViewUser(Item.Index);
      if UserSocket <> nil then
        with Item, UserSocket do
        begin
          if FSocket = INVALID_SOCKET then
          begin
            if OnLine then
              Caption := '断开'
            else
              Caption := '关闭';
          end
          else
            Caption := '保持';
          bug:='594';
          SubItems.Add(CurrentAction);
          SubItems.Add(FundAccount);
          SubItems.Add(UserName);
          SubItems.Add(ComeFrom);
          SubItems.Add(inttostr(ReqCount));
          SubItems.Add(inttostr(ReqBytes));
          SubItems.Add(inttostr(AnsBytes));
          SubItems.Add(inttostr(LastReqBytes));
          SubItems.Add(inttostr(LastAnsBytes));
          SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LastReqTime));
          SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LastAnsTime));
          if LastAnsTime >= LastReqTime then
            SubItems.Add(Format('%.3f', [LastAccessTimeCount / 1000]))
          else
            SubItems.Add('--.---');
          SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LoginTime));
          SubItems.Add(inttostr(LastCVTType));
          SubItems.Add(FromAddress);
           end;
      

  6.   

    这样不行的我是用timer 不停的刷新,有问题的
      

  7.   

    你真三,呵呵,别生气
    刷新按钮进去timer停一下,临出来前再把timer启起来。
      

  8.   

     timer事件
     try
      if not Assigned(Users) then
        Exit;
      AuxTimer.Enabled := False;
      if ListViewThread.Items.Count <> Users.ThreadCache.count then
          ListViewThread.Items.Count := Users.ThreadCache.count;
      ListViewThread.Refresh;
     finally
           AuxTimer.Enabled := True;
     end;
      

  9.   

    那啥。
    你为啥要写在onData里面啊
    DescriptionUse OnData to customize an item before it is displayed in the list view control. Set the properties of the list item in the event handler so that they appear correctly when the item is drawn.OnData occurs only if OwnerData is true.我还真没在这个事件里写过代码尼
      

  10.   

    ListViewThread.Refresh;这个的内容是啥子
      

  11.   

    Timer的问题!
    把Timer时间设长些,OnTimer事件中里面加个  Application.ProcessMessages
    如果还不行就自己写线程,别用Timer。
      

  12.   

    Application.ProcessMessages,sleep 都试过了
      

  13.   

    1.先将ListViewThread的Ondata代码去掉.使用自己写的过滤重复IP的代码.
    //添加的新IP信息先保存在一个StringList中,添加前判断StringList中是否存在,如果存在则不添加.
    不如将你的程序改为一有数据就会添加到ListViewThread里边,这样就避免了刷新界面无响应的问题.
    2.Timer事件的代码没有问题!
    你不加ListViewThread.Refresh;这一句试试看怎么样.
    就当不向ListViewThread刷新数据.看是否还有无响应的问题.具体要看程序操作了.程序流程还有代码提供太少了...将可能会出现刷新时界面无响应的问题全部先注释掉测试一下(除必用代码外).