创建了一个线程,结果在线程create的时候,系统就报错"abstract error"了。代码如下:procedure TFrm_E2BTest.btbtn_sendClick(Sender: TObject); 
var 
  myurl:String;
  postpara,XmlStr:WideString;
  aThreadHttp:TThreadHttp; 
begin 
  myurl:=赋值;
  postpara:=赋值;
  XmlStr:=赋值;
  aThreadHttp:=TThreadHttp.create(myurl,postpara,XmlStr); 
end; type 
  TThreadHttp = class(TThread)   private 
    tURL:String; 
    tPostPara,tXmlStr:WideString; 
  protected 
    procedure Execute; override; 
  public 
    constructor create(aURL:String;aPostPara,aXmlStr:WideString); 
  end; var 
  mydir:String; implementation uses Unit_E2BTest, HPCounter; 
constructor   TThreadHttp.create(aURL:String;aPostPara,aXmlStr:WideString); 
begin 
    inherited   Create(true); //执行到这里时报"abstract error"
    FreeOnTerminate := true; 
    tURL := aURL; 
    tPostPara := aPostPara; 
    tXmlStr:=aXmlStr; 
end; 
procedure   TThreadHttp.Execute;
{
略;
}
        

解决方案 »

  1.   

    我仔细检查了代码,没有发现在哪里定义了抽象方法啊。
    除了excute部分,其他的代码都在上面了。
      

  2.   

     inherited  Create(false)试试 
      

  3.   

    Execute里是不是写了inherited?Execute是抽象方法,没有实现,如果在子类中写了inherited的话就出这样的错了
      

  4.   

    可能是继承抽象方法并且没有实现该过程,才导致这个错误  TExe_ProThread = class(TThread)
      private
        OwnerForm: TAccForm;
        FException: Exception;
        ProSucc:Boolean;
        ProSta:string;
        procedure DoExe_Pro;
        procedure DoHandleException;
        procedure ThreadDone(Sender: TObject);
      protected
        procedure Execute; override;
        procedure HandleException;
      public
        constructor Create(Owner: TAccForm;FLAG:String);
      end;constructor TExe_ProThread.Create(Owner: TAccForm;FLAG:String);
    begin
      OwnerForm:=Owner;
      ProSta := FLAG;
      inherited Create(True);
      FreeOnTerminate := True;
      Priority :=tpNormal;
    end;
    procedure TExe_ProThread.Execute;
    begin
      FException := nil;
      ProSucc := False;
      inherited;
      if Terminated then Exit;
      try
        DoExe_Pro;
      except
        ProSucc := False;
        HandleException;
      end;
    end;
    procedure TExe_ProThread.DoExe_Pro;
    begin
      ....
    end;
    procedure TExe_ProThread.DoHandleException;
    begin
      ....
    end;
    procedure TExe_ProThread.HandleException;
    begin
      inherited;
      .....
    end;
    .....
    我就这样用的没有报错,并且线程中加了异常捕获.