title: How can I suspend and resume layout in WPF?
body: <p>How can I suspend and resume layout in WPF?
  I heard that this is not necessary. But this is extremely necessary!</p>
  
  <p>I process a lot of change positions, and if they are rendered one by one, it creates a delay effect.</p>
  
  <p>Here are some code:</p>
  
  <pre>
  <code>
  CompositionTarget.Rendering += new EventHandler(Draw);
  void Draw(object sender, EventArgs e)
  {
     //Clean screen
     for (int i = mainCanvas.Children.Count - 1; i > -1; i--)
     {
       if (mainCanvas.Children[i] is PlayerUserControl || mainCanvas.Children[i] is Image)
       {
             mainCanvas.Children.Remove(mainCanvas.Children[i]);
       }
     }
     //DRAW FLOOR AROUND
     FloorService.FloorEntity[] floorsAround = floorService.selectFloorsAround(Player.id);
     for...
     {
          Image image = new Image();
          image.Source = new BitmapImage(new Uri("/" + floorsAround[i].ImageSource, UriKind.Relative));
          mainCanvas.Children.Add(image);
     }
  
     //DRAW PLAYERS AROUND
     //Its similar as draw floors around.
     ...
  }
  </code>
  </pre>