私はDelphiでURLをチェックしてそれらが稼働しているかどうかを確認するプログラムを作成しています。問題は、一部の Web サイトではこのアクションに少し時間がかかることです。10秒くらいでギブアップしてほしいです。私の質問は、一定の時間が経過した後にチェックを停止し、チェックするリストの次の項目に移動する方法はありますか?
更新コードを入れていないことをお詫びします。質問ではなく、必要なコードの量を特定しようとしています。
procedure TWebSiteStatus.Button1Click(Sender: TObject);
var
http: TIdHTTP;
url: string;
code: integer;
i: integer;
begin
for i := 0 to Memo1.Lines.Count - 1 do
begin
url := 'http://www.' + Memo1.Lines[i];
http := TIdHTTP.Create(nil);
try
try
http.Head(url);
code := http.ResponseCode;
except
on E: EIdSocketError do
begin
code := http.ResponseCode;
end;
on E: EIdHTTPProtocolException do
begin
code := http.ResponseCode;
end;
end;
ShowMessage(IntToStr(code));
Case code of
200:
Edit2.Text := Memo1.Lines[i] + ' website is ok';
301:
Edit2.Text := Memo1.Lines[i] + ' website has moved but works';
else
begin
Edit2.Text := 'Something is wrong with the ' + Memo1.Lines[i] + ' website';
down;
end;
end;
finally
http.Free();
end;
end;
end;
http.Head(url); を実行しているように
10 秒後に試行を停止するにはどうすればよいでしょうか