B
bjyplbx
Unregistered / Unconfirmed
GUEST, unregistred user!
我定义了一个线程类,里面用于采集网页信息
TGetOnePage = class(TThread)
protected
Furl: string;
FTmpFile: string;
FHttpGetPage: THttpCli;
FCustUrlList: TStringList;
procedure Execute;
override;
private
procedure HttpGetPageDocbegin
(Sender: TObject);
procedure HttpGetPageDocEnd(Sender: TObject);
public
constructor Create(url: string;
tmpdir: string);
destructor Destroy;
override;
end;
在create里,对FHttpGetPage初始化
begin
inherited Create(false);
FreeOnTerminate := true;
FHttpGetPage := THttpCli.Create(nil);
FHttpGetPage.OnDocbegin
:= HttpGetPageDocbegin
;
FHttpGetPage.OnDocEnd := HttpGetPageDocend;
end;
我在excute里执行
begin
FHttpGetPage.url := Furl;
FHttpGetPage.Get;
while (not Terminated)do
;
end;
在 HttpGetPageDocEnd 里处理数据并结束线程
begin
try
...
finally
Terminate;
end;
end;
在destory中释放FHttpGetPage
begin
if Assigned(FHttpGetPage) then
FreeAndNil(FHttpGetPage);
inherited;
end;
就报错了,对地址 00000000 访问,什么问题呢,我的这个写法是不是不和逻辑啊
TGetOnePage = class(TThread)
protected
Furl: string;
FTmpFile: string;
FHttpGetPage: THttpCli;
FCustUrlList: TStringList;
procedure Execute;
override;
private
procedure HttpGetPageDocbegin
(Sender: TObject);
procedure HttpGetPageDocEnd(Sender: TObject);
public
constructor Create(url: string;
tmpdir: string);
destructor Destroy;
override;
end;
在create里,对FHttpGetPage初始化
begin
inherited Create(false);
FreeOnTerminate := true;
FHttpGetPage := THttpCli.Create(nil);
FHttpGetPage.OnDocbegin
:= HttpGetPageDocbegin
;
FHttpGetPage.OnDocEnd := HttpGetPageDocend;
end;
我在excute里执行
begin
FHttpGetPage.url := Furl;
FHttpGetPage.Get;
while (not Terminated)do
;
end;
在 HttpGetPageDocEnd 里处理数据并结束线程
begin
try
...
finally
Terminate;
end;
end;
在destory中释放FHttpGetPage
begin
if Assigned(FHttpGetPage) then
FreeAndNil(FHttpGetPage);
inherited;
end;
就报错了,对地址 00000000 访问,什么问题呢,我的这个写法是不是不和逻辑啊