title: Operations in separate TThread block GUI thread
body: <p>I used this tutorial <a href="http://delphi.about.com/od/kbthread/a/thread-gui.htm" rel="nofollow">http://delphi.about.com/od/kbthread/a/thread-gui.htm</a> to create a class that asynchronously downloads a file from the internet in another thread with a <code>TDownLoadURL</code>. I did this because I want to download a file without blocking the UI thread so the program doesn't become unresponsive during large downloads, the progress bar can update, etc.</p>
  
  <p>I am having a problem because even though I have done the download in another thread (inheriting from TThread and doing the work in the Execute method) the GUI thread seems to be blocked and does not process messages until the download is finished. Here is the code for my class: <a href="http://codepad.org/nArfOPJK" rel="nofollow">http://codepad.org/nArfOPJK</a> (it's just 99 lines, a simple class). I am executing it by this, in the event handler for a button click:</p>
  
  <pre><code>var
      frame: TTProgressFrame;
      dlt: TDownloadThread;
  begin
      dlt := TDownloadThread.Create(True);
      dlt.SetFile('C:\ohayo.zip');
      dlt.SetURL('http://download.thinkbroadband.com/512MB.zip');
      dlt.SetFrame(frame);
      dlt.SetApp(Application);
      dlt.Start;
  </code></pre>
  
  <p>Note: The SetApp method was for when I was manually calling <code>app.ProcessMessages</code> from inside the <code>UpdateDownloadProgress</code> method of my class <code>TDownloadThread</code>. This would keep the GUI from being unresponsive, but it made the progress bar behave wierdly (the moving glowing light thing of aero's progress bar moving way too fast), so I removed it. I want to fix this properly, and if I have to call <code>ProcessMessages</code> there's really no point in multithreading it.</p>
  
  <p>Can someone help me fix this problem? Thanks.</p>