Improve Windows Forms performance
This post is particularly for me as I always forgot those great tips and hard to find them back in MSDN Magazine or other resources, so I figure by putting them here will end up using them more also dear reader enjoy them too I'm sure you will find something you don't know or forgot a while ago.
fire your application faster
You can accomplish this by many ways starting with not populating the databoud controls in the load event directly instead have them on serrate thread so they don't block the UI while they linking to data source and rendering.
If you are using .NET 2.0 then you pleased with the new BackgroundWorker component that will delegate the work into background thread - will talk in details about BackgroundWorker in other post .
Now the most important part which is will boost your application startup is using native image generator NGen which is available with .NET Framework SDK since version 1.1 at least.
couple of days ago I have attended session about improving application startup performance by NGen within MDC presented by Surupa Biswas Program Manager on CLR Team and with the demo she showed us the difference between launching Microsoft Expression Blend with and without NGen images like the difference between shooting a bullet and throwing it and this also speak of a seprate post.
faster UI and Controls rendering
Always use BeginUpdate() and EndUpdate() to supress repaiting the controls while it's collection changing like the case of ListBox and ComboBox.
The neat trick i wouldn't thought of before by Milena Salman is when you hard code the data binding to a control is to assign the Control.ValueMemebr first then Control.DataSource couse assining the data source first will couse the control to repopulate.
Also notice that if you add controls at runtime, change or resize any existing controls will couas the parent control to fire Control.Layout event, so be sure to use SuspendLayout and ResumeLayout on the parent control when playing with the child controls.
Don't lean much on garbage collector
Not becouse GC will let you down but for instant finalizing managed resourses within your code is less expensive by letting GC do the job also don't forget to use the using keyword with unmanaged resources, if you do finalize an unmanaged resource by yourself call the GC.SuppressFinalization to save a GC cycle.