Click here to Skip to main content
15,917,928 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# windows app Pin
Anthony_Yio25-May-04 20:05
Anthony_Yio25-May-04 20:05 
GeneralRe: C# windows app Pin
Nick Seng25-May-04 20:07
Nick Seng25-May-04 20:07 
GeneralRe: C# windows app Pin
Anthony_Yio25-May-04 20:16
Anthony_Yio25-May-04 20:16 
GeneralRe: C# windows app Pin
Nick Seng25-May-04 20:21
Nick Seng25-May-04 20:21 
GeneralRe: C# windows app Pin
Anthony_Yio25-May-04 20:35
Anthony_Yio25-May-04 20:35 
GeneralRe: C# windows app Pin
Anthony_Yio25-May-04 20:45
Anthony_Yio25-May-04 20:45 
GeneralRe: C# windows app Pin
Dave Kreskowiak26-May-04 2:48
mveDave Kreskowiak26-May-04 2:48 
GeneralRe: C# windows app Pin
Heath Stewart26-May-04 4:19
protectorHeath Stewart26-May-04 4:19 
You should definitely read the newest Patterns and Practices book, Improving .NET Application Performance and Scalability[^]. It's good for any newbie, intermediate, or advanced developer.

Specifically for what I wanted to mention, you should take a look at Finalize and Dispose Explained[^] and the following 2 or 3 sections in Chapter 5 of that book.

Disposing objects is a big advantage. Since almost all Windows Forms controls (and many other classes in the .NET FCL) encapsulate native functions and resources - called unmanaged resources because they're not managed by the runtime Garbage Collector (GC) - they need to be disposed. The controls in Windows Forms will take care of this for you since they follow the common pattern, but disposing them when you're done will improve performance since the object is freed and the GC won't need to collect it later.

This is especially important if you use Form.ShowDialog. If you read the documentation for ShowDialog, you'll see that it says you must dispose it. This has something to do, IIRC, with the message pump created to handle the dialog (though this isn't necessary for Show). A good way to make sure this - and other objects - are disposed - even in case of error - is to use the using statement like so:
using (MyForm form = new MyForm())
  form.ShowDialog();
Boxing and unboxing is also a big hit on performance. Value types - like the primatives, enums, and structs - are allocated on the stack. When you treat them as an Object, they are boxed. When you cast that Object back to a value type, it is unboxed. This is very detrimental. For now, all you can do is suffer or rewrite many of the common classes like ArrayList that many use to store value types. With .NET 2.0, C# (and other languages) are gaining support for generics (templates in C/C++). This will greatly improve performance since a value type would be stored and accessed as a value type with boxing and unboxing.

The Patterns and Practices book has a lot more information I'm sure you'll find useful.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: C# windows app Pin
Anthony_Yio26-May-04 15:33
Anthony_Yio26-May-04 15:33 
Questionhow to empty the system chache in TCP connection? Pin
fu025-May-04 17:49
fu025-May-04 17:49 
GeneralForms Pin
Anonymous25-May-04 17:24
Anonymous25-May-04 17:24 
GeneralRe: Forms Pin
Anonymous25-May-04 18:41
Anonymous25-May-04 18:41 
GeneralRe: Forms Pin
Anonymous25-May-04 18:44
Anonymous25-May-04 18:44 
General[Message Deleted] Pin
ProductShowcase25-May-04 17:02
ProductShowcase25-May-04 17:02 
GeneralRe: Is there an #define for the compiler version? Pin
Anthony_Yio25-May-04 20:47
Anthony_Yio25-May-04 20:47 
GeneralRe: Is there an #define for the compiler version? Pin
Dave Kreskowiak26-May-04 2:57
mveDave Kreskowiak26-May-04 2:57 
GeneralRe: Is there an #define for the compiler version? Pin
Marc Clifton26-May-04 3:25
mvaMarc Clifton26-May-04 3:25 
GeneralRe: Is there an #define for the compiler version? Pin
Heath Stewart26-May-04 4:23
protectorHeath Stewart26-May-04 4:23 
GeneralTooltips Pin
Joel Holdsworth25-May-04 10:11
Joel Holdsworth25-May-04 10:11 
GeneralRe: Tooltips Pin
Heath Stewart25-May-04 10:37
protectorHeath Stewart25-May-04 10:37 
GeneralRe: Tooltips Pin
Heath Stewart25-May-04 11:25
protectorHeath Stewart25-May-04 11:25 
Generaladding dataset to webform generating error Pin
DeSonny25-May-04 10:00
DeSonny25-May-04 10:00 
GeneralWrite DataGrid to file. Pin
Jason Weibel25-May-04 9:28
Jason Weibel25-May-04 9:28 
GeneralRe: Write DataGrid to file. Pin
Heath Stewart25-May-04 9:57
protectorHeath Stewart25-May-04 9:57 
GeneralWisdom of deriving a control from Panel Pin
Joel Holdsworth25-May-04 9:08
Joel Holdsworth25-May-04 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.