title: How to prevent MDI windows being closed before app finished processing
body: <p>I have an MDI application in which I have a MDI child doing some processing (needs 10-20 seconds to finish). I have discovered that if I close the main application, it crashes because the MDI child is closed to early (before finishing its processing).</p>
  
  <p>The code is like this (it is way too complicated to put all code in here):</p>
  
  <pre><code>mainForm.OnButtonClick
  begin
    start data processing;                         &lt;--- 10 seconds
    create MDI child;                              &lt;--- instant
       create visual controls (runtime)            &lt;== 
          display the processed data in MDI child; &lt;== 1 sec
  end;
  </code></pre>
  
  <p>The program crashes on the 3rd line. FastMM says that "FastMM has detected an attempt to call a virtual method on a freed object". Obviously the MDI child has been freed.</p>
  
  <p>How to prevent this?</p>