delphi 6里面新建线程
线程代码如下:
unit Un_GetDFServer;interfaceuses
  Classes,OAFDIWebService,SyncObjs,dialogs,windows,ADODB,DB;type
  Test = class(TThread)
  constructor Create(const url:string;const UserID: Integer; const Pwd: String;ef:TSimpleEvent;query:Tadoquery);
  private
    _url : String;
    _UserId : Integer;
    _Pwd : String;
    _GetLmListResult: ErrorCode;
    _LmInfo: ArrayOfLmNode;
    _ef:TsimpleEvent;
    _query :TAdoquery;
    { Private declarations }
  protected
    procedure Execute(); override;
  published  end;implementationuses MainForm;{ Important: Methods and properties of objects in VCL or CLX can only be used
  in a method called using Synchronize, for example,      Synchronize(UpdateCaption);  and UpdateCaption could look like,    procedure TGetDFServer.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }{ TGetDFServer }{ TGetDFServer }constructor Test.Create(const url: string; const UserID: Integer;
  const Pwd: String;ef : TSimpleEvent;query:Tadoquery);
begin
 
  _url := Url;
  _Pwd := Pwd;
  _UserId := UserId;
  _GetLmListResult := nil;
  _LmInfo := nil;
  _ef := ef;
  FreeOnTerminate:=true;
  _query := query;
  inherited Create(false);end;procedure Test.Execute();
var i : integer;
begin
 try { GetOAFDIWebServiceSoap(false, _url).GetLmList(_UserID, _Pwd, _GetLmListResult, _LmInfo);
  frmMain.GetLmListResult := _GetLmListResult;
  frmMain.LmInfo :=  _LmInfo ;
  frmMain.IsComplete := true;
  _GetLmListResult := nil;
  _LmInfo := nil;
  }
  if _query<> nil then
  _query.Open();
  while not _query.Eof do
  begin
      _query.Next;
  end;
  //OAFDIWebService.GetOAFDIWebServiceSoap(false,_url).GetLmList(_userId,_Pwd,_Getlmlistresult,_lminfo);
  frmmain._GetLmListResult := _Getlmlistresult;
  frmmain._LmInfo := _lminfo;
 except
  {_ef.SetEvent;             }
  frmMain.IsComplete := true;
 end;
end;end.
调用过程如下;
var
  ec: ErrorCode;
  lms: ArrayOfLmNode;
  t: Test;
  ef : TSimpleEvent;
  a : TWaitResult;
begin
  Loading := true;  if not Assigned(LmInfoList) then LmInfoList := TLmNodeCollection.Create;  //修改的地方
  //LmInfoList.Clear;
 // ec := nil;
 // lms := nil;
  //修改结束
  ef := TSimpleEvent.Create;
  try
   t:=    test.Create(RegSetup.WebServiceURL,RegSetup.UserID,RegSetup.UserPWD,ef,adoquery1);
   a := ef.WaitFor(10);
   while not isComplete do
   begin
        application.HandleMessage;
   end;
  except
end;
提示错误信息:尚未调用Colinitialize