不知为何我的线程老是半途出错??!
我的代码如下:unit Unit15;
interface
uses
Windows,Classes,Sysutils;
type
TCheckUrl = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create;
end;
implementation
uses
Unit2,Unit3;
constructor TCheckUrl.Create;
begin
inherited Create(true);
end;
procedure TCheckUrl.Execute;
var
CurTime:LongWord;
DelayTime:LongWord;
Tag_Value:integer;
Address_Chk:string;
begin
with CheckLinksForm.DBISAMTable do
begin
TableName:='UrlAddress.dat';
Exclusive:=False;
ReadOnly:=False;
Open;
First;
while not EOF do
begin
Url_True_False:=False;
Address_Chk:=MainForm.DenCrypt(Trim(FieldByName('Url').AsString),'');
if Address_Chk<>'' then
begin
try
CheckLinksForm.NMhttp1.head(Trim(Address_Chk));
//设置时间延迟为0.5秒
DelayTime:=5000;
CurTime:=GetTickCount;
while (GetTickCount<(CurTime+DelayTime)) do
if Url_True_False=True then break;
CheckLinksForm.NMhttp1.Cancel;
if Url_True_False=True then
begin
Address_Chk:=Address_Chk+' ......Ok!';
CheckLinksForm.Memo1.Lines.Add(Address_Chk);
Tag_Value:=2;
end
else
begin
Address_Chk:=Address_Chk+' ......Failure!';
CheckLinksForm.Memo1.Lines.Add(Address_Chk);
Tag_Value:=1;
end;
except
Url_True_False:=False;
Address_Chk:=Address_Chk+' ......Failure!';
CheckLinksForm.Memo1.Lines.Add(Address_Chk);
Tag_Value:=1;
end;
//fieldbyname('Tag').value:=Tag_Value;
//fieldbyname('M_Date').value:=DatetimeToStr(Now);
//Post;
end;
next;
if Terminated then Exit;
end;
end;
CheckLinksForm.button2.caption:='Finished';
end;
end.