1、我在网上下载一个图片使用了线程但是感觉还是有一种假死机的情况,这是为什么?
2、多有两个过程都要很长的时间才能处理完成,并且它们的结果是相互调用的,请问怎么做这个线程?
3、为什么执行以下的线程会有假死机的情况?怎么解决假死机的情况?
unit UIndustry;interfaceuses
  Classes,MandiQ,SysUtils, Rio, SOAPHTTPClient,shellApi,Forms,Windows,RzLstBox;
  var
   CS:TRTLCriticalSection;
type
  TIndustry = class(TThread)
  private
    RB: TRzListBox ;
    Bigtrade:ArrayOfArea;
    { Private declarations }  protected
    procedure Execute; override;
     procedure doFun;
  public
    Constructor Create(Rlb:TRzListBox);   //TempArry 返回的大类信息
  end;implementation{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,      Synchronize(UpdateCaption);  and UpdateCaption could look like,    procedure TIndustry.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }{ TIndustry }constructor TIndustry.Create(Rlb: TRzListBox);
begin
  Rb:=Rlb;
  //Bigtrade:=TempArry;
  inherited Create(False);
end;
procedure TIndustry.Execute;
begin
  Synchronize(doFun);
end;
procedure TIndustry.doFun;
var
  Area:ArrayOfArea;
  i:integer;
  HTTPRIO1: THTTPRIO;
  S:String;
begin
  Application.Initialize;  HTTPRIO1:=THTTPRIO.Create(Application);
  Area:=nil;
  HTTPRIO1.WSDLLocation:='http://www.163.com/TestWS/services/Test?wsdl';
  try
    Area:=(HTTPRIO1 as MandiQPortType).getAllTradeBig;
    Bigtrade:=Area;    //返回数组信息
    for i:=0 to High(Area) do
    begin
    RB.Items.Add(Area[i].name);
    end;  except
    Application.MessageBox('连接Web Service失败!','提示',MB_ICONERROR );
  end;
end;end.

解决方案 »

  1.   

    設timeout, 包括connection,send 和 receive timeout.
      

  2.   

    我调用的方法如下:
    var
      Industry:TIndustry;
    begin
      Industry:=TIndustry.Create(RzListBox1);
      Timer1.Enabled:=false;
    end;
      

  3.   

    多线程也是执行的程序。在执行网络和数据库连接相关程序时这种现象比较普遍,比如sql2000本身也有这个问题。这种问题只能有缓解的方法,根本没有彻底解决的办法,因为它取决于你的网络等条件。
    缓解的方法有一些,比如楼上说的设置连接超时等属性,
    还有可以使用Sleep方法,空出一些CPU的时间片给其他进程使用,
    使用Application。processMessages,让系统在执行中间,有限处理一下消息,再继续执行代码等等
      

  4.   

    因为你把doFun;同步到了主线程,如果SOAP连接很慢,看起来就是“程序没有响应”,要解决也只有不要在主线程调用这个SOAP.