title: What is the best way to call a procedure "delayed"?
body: <p>There are two procedures, A1 and A2, which both call function B in their code:</p>
  
  <pre><code>function B: boolean;
  begin
    // do other stuff
  end;
  
  procedure A1;
  begin
    // do stuff
    if b then
      ...
    // do stuff
  end;
  
  procedure A2;
  begin
    // do stuff
    if b then
      A1; // &lt;- how to call A1 "delayed"?
    // do stuff
  end;
  </code></pre>
  
  <p>If the condition in A2 is true, procedure A1 must be called, but that would happen while A2 is still running, which I don't want.</p>
  
  <p>What should happen is:
  If the condition in A2 is true, then A2 should be finished and after leaving A2 the procedure A1 should be called.</p>
  
  <p>An ugly solution would be to set a timer that calls A1 after a delay that makes sure A2 is finished.</p>
  
  <p>But there must be better ways, right?</p>
  
  <p><strong>EDIT</strong>: A1 and A2 in my case are events, so they are not called by code and I cannot just call A1 from a calling procedure after A2 is finished.</p>