Tips For Boosting .NET WinForm Performance

In this MSDN article, tips were suggested for boosting .NET WinForm Performance and I summarized as follows.

  1. Load fewer modules at startup
  2. Precompile assemblies using NGen
  3. Place strong-named assemblies in the GAC
  4. Avoid base address collisions
    • dumpbin can check the preferred base address of Dlls.
  5. Avoid blocking on the UI thread
  6. Perform lazy processing
    • Some operations can be implemented in the Idle event and will be processed when applications are idle.
  7. Populate controls more quickly
    • The following code snippet shows how to avoid constant repainting.
      listView1.BeginUpdate();
      for(int i = 0; i < 10000; i++)
      {
      ListViewItem listItem = new ListViewItem("Item"+i.ToString() );
      listView1.Items.Add(listItem);
      }
      listView1.EndUpdate();
  8. Exercise more control over data binding
    • BindingSource can help improve performance.
      this.bindingSource1.SuspendBinding();
      for (int i = 0; i < 1000; i++)
      {
      tbl.Rows[0][0] = "suspend row " + i.ToString();
      }
      this.bindingSource1.ResumeBinding();
  9. Reduce repainting
    • Use SuspendLayout method whenever possible to minimize the number of Layout events.
    • Call Invalidate method and pass the area that needs to be repainted as an argument to Invalidate.
  10. Use double buffering
  11. Manage memory usage
    • If controls are added and removed from WinForm dynamically, call Dispose on them. Otherwise, extra unwanted handles would be accumulated in the process.
  12. Use reflection wisely

 

posted on 2008-04-23 14:10  TeeBye  阅读(1636)  评论(0编辑  收藏  举报

导航