title: How to show a busy indicator for a long non-ajax operation?
body: <p>I have a function that's running for 2-3 seconds on the client (no ajax calls).
  I'm trying to show a "Busy/Processing" animation while this operation is running.</p>
  
  <p>simplified code is as followed:</p>
  
  <pre><code>var ajaxContainer = $('.spinner');
  // show
  $(ajaxContainer ).show();
  
  // long operation
  var items = GetItems();
  $.each(items, function (index, value) {
      ProcessItem(value.itemID);
  });
  
  // hide
  $(ajaxContainer ).hide();
  </code></pre>
  
  <p>but this does not work as expected. the result that i get is that the operation runs without showing the spinner. although it does show when the operation ends.</p>
  
  <p>I saw some posts online mentioning that this could be done by using <strong>windows.setTimeout()</strong>. but since this operation is based on a dynamic number of items i would not want to set a specific timeout number in advance. instead i'd like to show the spinner when the operation starts, and hide it when it's finished.</p>
  
  <p>is there an elegant way to achieve this?</p>