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.

      for(int i = 0; i < 10000; i++)
      ListViewItem listItem = new ListViewItem(“Item”+i.ToString() );

  8. Exercise more control over data binding
    • BindingSource can help improve performance.

      for (int i = 0; i < 1000; i++)
      tbl.Rows[0][0] = “suspend row ” + i.ToString();

  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


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )


Connecting to %s