THttpThread
ファイルのダウンロード用に定義されたスレッドがあります。モーダルフォームが閉じられた場合やキャンセルボタンが押された場合にダウンロードを中止したい。
以下の例では、おそらくスレッドを再利用する方法が原因で、アクセス違反が発生しました。
procedure Tform_update.button_downloadClick(Sender: TObject);
var
HttpThread: THttpThread;
begin
//download
if button_download.Tag = 0 then
begin
HttpThread:= THttpThread.Create(True);
//...
HttpThread.Start;
end
//cancel download
else
begin
HttpThread.StopDownload:= True;
end;
end;
TIdHTTP を使用してダウンロードを停止 (キャンセル) する方法と他の多くの方法から答えを見つけましたが、実行中のスレッドのプロパティを更新する方法はまだわかりません。