我定义一个线程
type
 findbt=class(TThread)//创建发现内容的线程
 private
 protected
   function _Get(url: String) : String;
   Procedure Execute;override;
 public
end;在procedure findbt.Execute
var
 idhttp:tidhttp;
 a:integer;
begin
 idhttp:=tidhttp.create(nil);
 a:=0;
 while a=0 do
 begin
   s:=_get('http://xxx.xxx.xxx');//我想在_get函数中使用上面的IDHTTP如何用啊?不想在_get()中一直动态创建再删除.
 end;end;

解决方案 »

  1.   

    把 idhttp:tidhttp; 作为线程类的一个变量
      

  2.   

    tidhttp是非界面控件,线程内创建、仅仅本线程使用,应该不用同步
      

  3.   

    TidHTTP好像是现成安全的VCL组件查询一下吧,只要做成类得一个私有成员,构造函数里面创建,析构函数里面释放就行了很简单。
      

  4.   

    还不如用ICS控件,非阻塞,支持异步,连线程都不用写