title: Delphi "UI updating" issue of content provided by a thread
body: <p>I'm writing a small Delphi 10.3 VCL Win32 application for viewing a bunch of SVG images.  Yes, there must be application that does exactly what I want but I'm using this as a bit of a learning opportunity.</p>
  <p>It renders each image and a label indicating the image name so you can quickly scroll through them.</p>
  <p>I decided to thread it so the user doesn't need to wait until all the images have been loaded.</p>
  <p>This was nice except that the main form isn't painting or processing user &quot;messages&quot; while the loading occurs.</p>
  <p>I'm calling the method below via the thread's Synchronize( ) method.</p>
  <pre><code>procedure TFinderThread.CreateControlsForNextItem;
  var
    img: TcxImage;
  begin
    svg:=TdxSmartImage.Create;
    svg.LoadFromFile(m_slFiles[0]);
    m_slFiles.Delete(0);
  
    // omitted:  TLabel creation
  
    img := TcxImage.Create(m_owner);
    img.Left := 0;
    img.Top := m_iNextControlTop;
    img.Picture.Assign(svg);
    img.Parent := m_parent;
    m_iNextControlTop:=m_iNextControlTop + img.Height;
  
    svg.Free;
  end;
  </code></pre>
  <p>I'd like the main form to be responsive and usable while it's being loaded.  I found that a short call to Sleep( ) in the thread's Execute loop makes the UI responsive.</p>
  <p>the Execute method contains this loop:</p>
  <pre><code>m_iNextControlTop:=0;
  while m_slFiles.Count&gt;0 do
    begin
      if Terminated then
        break;
  
      Synchronize(CreateControlsForNextItem);
      sleep(1);
    end;
  </code></pre>
  <p><strong>The problem</strong></p>
  <p>If you use the scroll bar during refresh, some controls don't appear at all in the scroll box.  The objects exist, are visible, have the correct parent, etc.  This is doesn't change if you later scroll around so it doesn't appear to be a &quot;painting&quot; issue.  It's as though the scrollbox doesn't recognize them as content.</p>
  <p>If you don't scroll at all during refresh, all the images will appear correctly.</p>
  <p>Any idea what's happening?</p>
  <p>Thanks!</p>