title: Javascript: Non-blocking way to wait until a condition is true
body: <p>I have several ASP.NET UpdatePanels, each with an AsyncPostBackTrigger tied to the same button's serverside click event.  Since only one UpdatePanel can be doing its thing at a time, I use <code>.get_isInAsyncPostBack()</code> of the <code>PageRequestManager</code> to prevent a user from being able to access another part of the page until the async postback is complete.</p>
  
  <p>Another part of this page needs to dynamically update multiple update panels consecutively.  Since the update panels use async triggers, calling <code>__doPostBack("&lt;%=ButtonName.ClientID %&gt;", 'PanelId');</code> fires asynchonously.  Because of this, it will quickly move along to the next iteration of the loop and try to update the next panel.  However, the second iteration fails because there is already another update panel doing an async postback.</p>
  
  <p>Ideally, there would be a way to wait until <code>.get_isInAsyncPostBack()</code> returns false without blocking other client activity.</p>
  
  <p>Research has lead me to a lot people with my problem, almost all of whom are advised to use <code>setTimeOut()</code>.  I do not thing this will work for me.  I don't want to wait for a specified amount of time before executing a function.  I simply want my Javascript to wait while another script is running, preferably wait until a specific condition is true.</p>
  
  <p>I understand that many will probably want to suggest that I rethink my model.  It's actually not my model, but one that was handed to our development team that is currently a total mess under the hood.  Due to time contraints, rewriting the model is not an option.  The only option is to make this work.  I think that if I had a way to make the client code wait without blocking, my problem would be solved.</p>