Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
See more:
May I get some tips to optimize the speed of Windows application
any good advises will be appreciated.
Posted

The first step would be to find the points of bad performance. Then show us the piece of code where you need to optimize, and then, maybe someone here will find a solution.
 
Share this answer
 
Comments
Ajain A K 25-Feb-11 6:09am    
hai thomas thanks for your response. The question I am asking is genearl
not specific to any particular piece of code plese give me a generic explanation.
avoid data base connections in loops
avoid unnecessary conversions
 
Share this answer
 
Comments
Ajain A K 25-Feb-11 6:11am    
Thanks a lot please give some more explantion if it is possible.
Hello

1.The thing that is a big headache of performance is handling exceptions.So, if you create your own ApplicationExeptions, try to avoid throwing them rather that handle them afterwards.However, do not remove try ...
catch blocks, they can reduce performance ONLY when they handle real exception.

2.Write code with explicit type conversions(do not let CLR do type conversions instead of you), because it also reduces performance significantly

3.You can try using insertions of C++ code, when you are handling rather complicated calculations

4.Try avoid using Switch{} within another switch{}

5.Do not use System.Drawing features(cause they are based on old engine)
 
Share this answer
 
v2
Comments
Ajain A K 1-Mar-11 3:59am    
Thanks friend.
You got it man.....Here you go....It contains a massive collection.

Best Practices

Some Best Practices for C# Application Development[^]

Some Best Practices for C# Application Development (Explained)[^]

EDIT
-------------------------------------------
Yeah Now Agree with SA because don't want that mislead(refer the comments below my answer). So careful with things(select only what you want).

Optimizations

C# Optimization Tips and Secrets[^]

Writing Faster Managed Code: Know What Things Cost[^]

Writing High-Performance Managed Applications : A Primer[^]

Performance Tips and Tricks in .NET Applications[^]

Rico Mariani's Performance Tidbits[^]

Optimization 101[^]

Database Optimizations - .NET

Tips For Database Optimization/Operations with C#[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 25-Feb-11 17:20pm    
About half of advices... not even bad... They are advised without connection to the application, so my critique would be: "this is only good is this and this case, in other cases, it should be...". You see? If you apply these without thinking, they mislead, if with good thinking -- they are redundant.
--SA
thatraja 25-Feb-11 18:33pm    
oh come on SA :-), he didn't mentioned about connection or even didn't posted his code then how can I give him Solutions in that way. Also some of things(string builder, IDisposable, etc.,) in those articles surely will help to optimization. Also I assumed that he need best practices things based on his question so I gave him this.
Sergey Alexandrovich Kryukov 25-Feb-11 18:56pm    
I agree. That's why I did not any advise. I only say the article a not good, really. I can go item by item. Advice are shallow and not helping by the reason I tried to explain.
--SA
thatraja 25-Feb-11 19:14pm    
Agree but it's a worth one for beginners. Then why don't you post your answer...just post what you got for this. Even It may be useful for me.
Sergey Alexandrovich Kryukov 25-Feb-11 19:35pm    
No, I disagree. It may be interested for the experienced, but can mislead the novice.
To post item-by-item notes, I need time. Thank you for advice, anyway, I'll think.
For advise on optimization, I have only one: "do not optimize prematurely!".
--SA
Few tips to optimize code:
1. Use StringBuilder instead of String (for manipulation )
2. Use List<>/ Dict<,>; instead of arraylist/ Hashtable....
3. Use Try Catch only when necesssary...
4. Use Asynchronous Programming where ever possible.
 
Share this answer
 
Comments
Ajain A K 25-Feb-11 6:10am    
thanks a lot
[no name] 25-Feb-11 6:52am    
its my pleasure.

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