title: Sleep / pause a function in c#
body: <p>I am making an app for wp 7.x/8.</p>
  
  <p>There is a function like -</p>
  
  <pre><code>public void draw()
  {
      .............
      ImageBrush imgbrush = new ImageBrush();
      imgbrush.ImageSource = new BitmapImage(...);
  
      rect.Fill = imgbrush;  //rect is of type Rectangle that has been created 
                             //and added to the canvas
      ........
  }
  </code></pre>
  
  <p>and another function</p>
  
  <pre><code>private void clicked(object sender, RoutedEventArgs e)
  {
      draw();
      ........
      if (flag)
      {
            Thread.sleep(5000);
            draw();
      }
  }
  </code></pre>
  
  <p>But when the button is clicked the result of both the draw operation appear simultaneously on the screen.</p>
  
  <p>How to make the result of second draw() operation to appear after some delay?</p>
  
  <p>Or is there something like buffer for the screen, until the buffer is not filled the screen will not refresh?</p>
  
  <p>In that case, how to FLUSH or Refresh the screen explicitly or force the .fill() method of Rectangle to make the changes on the screen?</p>
  
  <p>Any help in this regard would be highly appreciated.</p>