Click here to Skip to main content
15,567,786 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,

I have written an application in c# and was surprised with the speed.

I want to know how I can increase the speed of the application???

For example:

  • use generic

  • use 'for loop' instead of 'foreach'

  • use StringBuilder

  • use threading

But, the speed of my application is still very slow??

<pre lang="cs">//***********************************************
       void FillType()
           objType = new BL.BL.Type();
           cmbType.DataSource = objType.GetType();
           cmbType.DisplayMember = "TypeName";
           cmbType.ValueMember = "TypeID_FK";
       void FillLanguage()
           objLanguage = new BL.BL.Language();
           cmbLanguage.DataSource = objLanguage.GetLanguage();
           cmbLanguage.DisplayMember = "LanguageName";
           cmbLanguage.ValueMember = "LanguageID_FK";
       void FillDocument()
           dgvDocument.AutoGenerateColumns = false;
           bsDocument = new BindingSource();
           objDocument=new BL.BL.Document();
           bsDocument.DataSource = objDocument.GetDocument();
           dgvDocument.DataSource = bsDocument;

 private void frm_ListDocument_Load(object sender, EventArgs e)

Updated 19-May-11 5:16am
Groulien 19-May-11 9:36am    
Slow app = slow code
1. What kind of program are you working on?
2. Post the code.
Programm3r 19-May-11 9:42am    
I agree, you'll have to post some code...

1 solution

You'll have to profile your application to analyze where most of the time is spent in your code. Visual Studio has a profiler on board I think, but there also many good ones out in the wild:

  1. Yourkit[^]
  2. JetBrains[^]
  3. RedGate ANTS[^]
  4. EQUATEC[^]

Google for "Free .NET Profiler" and I'm sure you can come up with a couple of free ones yourself.

Profiling code performance will pinpoint the bottlenecks in your application and you'll have to analyze what kind of tuning mechanisms could be applied.

Cheers and happy profiling!

Share this answer
fjdiewornncalwe 19-May-11 10:26am    
Excellent Suggestions. +5.
thatraja 23-May-11 22:54pm    
Good bunch
Sergey Alexandrovich Kryukov 6-Jun-11 12:58pm    
Agree, my 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900