title: How to handle events on the main thread before next loop iteration
body: <p>I have a loop that creates more UI at each iteration. This means I can hardly use concurrency here. The whole sequence blocks the main thread for a long time since it's quite heavy. I'd like to detect the tap gestures that were done so that I can cancel the long processing if the user decides to go in another menu. What I would like is something like that:</p>
  
  <pre><code>while[...]:
    -Do a lot of UI-related operations
    -Force the main thread to handle gestures that were done 
     while the main thread was previously blocked
    -Continue to next iteration
  </code></pre>
  
  <p>I tried using <code>NSRunLoop.RunUntil</code> to force the "unclogging" of the event stack before going to the next iteration, but no avail. Anyways, I read that it is not a good practice since the RunLoop is not reentrant, even if I'm not exactly sure what that means. Any suggestions on how to proceed here?</p>
  
  <p>Thanks,</p>
  
  <p>Paul</p>