title: Delphi: Stop a download using IdHttp and Thread
body: <p>I have a thread defined <code>THttpThread</code> for downloading of a file. I would like to stop the download if modal form is closed or if Cancel button is pressed.</p>
  
  <p>In the example from bellow I got Access Violation probably because of the way how I reuse the thread.</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>I sow the answers from <a href="https://stackoverflow.com/questions/6922787/how-stop-cancel-a-download-using-tidhttp">How stop (cancel) a download using TIdHTTP</a> and some many others but I still don't get it how to update a property of a running thread.</p>