Click here to Skip to main content
15,902,189 members
Home / Discussions / C#
   

C#

 
AnswerRe: Why do my graphics still flicker? Pin
blackthunder00130-Mar-04 14:41
blackthunder00130-Mar-04 14:41 
GeneralRe: Why do my graphics still flicker? Pin
adonisv30-Mar-04 14:59
adonisv30-Mar-04 14:59 
AnswerRe: Why do my graphics still flicker? Pin
Anonymous30-Mar-04 20:11
Anonymous30-Mar-04 20:11 
GeneralI call Invalidate() Pin
adonisv31-Mar-04 16:43
adonisv31-Mar-04 16:43 
Questionhandling multiple connections? Pin
Anonymous30-Mar-04 12:21
Anonymous30-Mar-04 12:21 
AnswerRe: handling multiple connections? Pin
Heath Stewart30-Mar-04 12:54
protectorHeath Stewart30-Mar-04 12:54 
GeneralIDisposable Pin
blackthunder00130-Mar-04 10:01
blackthunder00130-Mar-04 10:01 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 10:17
protectorHeath Stewart30-Mar-04 10:17 
First, the Dispose(bool) method doesn't NOT need to be overridden and is not declared in IDisposable. IDisposable declares one method: void Dispose(). Dispose(bool) is a virtual method inheritted from Control. You can implement IDisposable on anything. You don't need to override Dispose(bool) unless you contain components that need to be disposed, like AxHost controls (ActiveX controls in a managed environment) and stuff like that.

Managed objects are managed by the garbage collector. They will be garbage collected when necessary. You typically implement IDisposable (or override Dispose(bool) in your controls) when you need to clean-up unmanaged resources like window handles, file handles, and the like. These things are unmanaged, i.e. they are not managed by the garbage collector (GC). Objects that don't need to free unmanaged resources can implement and use IDisposable to free managed resources, but should use GC.SurpressFinalize(this) in the Dispose() implementation to prevent the GC from wasting time cleaning it up (since you already did).

Other reasons for implementing IDisposable and for callers to call Dispose is to release resources immediately since the GC doesn't run continuously. This makes sure that resources (even managed resources) are released when you want them to be. For things like a Button, it typically doesn't matter. The GC will get around to it. Dispose it only if it's absolutely necessary (otherwise you degrade the performance of your application since the GC is taking time away from your program's execution).

See Programming for Garbage Collection[^] in the .NET Framework SDK for more information and examples.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: IDisposable Pin
blackthunder00130-Mar-04 14:32
blackthunder00130-Mar-04 14:32 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 16:24
protectorHeath Stewart30-Mar-04 16:24 
QuestionHow do i import/use these dll's ? Pin
mihaimarinescu30-Mar-04 8:53
mihaimarinescu30-Mar-04 8:53 
AnswerRe: How do i import/use these dll's ? Pin
Heath Stewart30-Mar-04 9:38
protectorHeath Stewart30-Mar-04 9:38 
AnswerRe: How do i import/use these dll's ? Pin
Dave Kreskowiak30-Mar-04 9:39
mveDave Kreskowiak30-Mar-04 9:39 
GeneralCasting again - from parent to child Pin
Grep30-Mar-04 8:31
Grep30-Mar-04 8:31 
GeneralRe: Casting again - from parent to child Pin
Heath Stewart30-Mar-04 9:43
protectorHeath Stewart30-Mar-04 9:43 
GeneralRe: Casting again - from parent to child Pin
Grep30-Mar-04 9:59
Grep30-Mar-04 9:59 
GeneralRe: Casting again - from parent to child Pin
Heath Stewart30-Mar-04 10:08
protectorHeath Stewart30-Mar-04 10:08 
QuestionIs this a pointer operation ? Pin
Andres Coder30-Mar-04 8:28
Andres Coder30-Mar-04 8:28 
AnswerRe: Is this a pointer operation ? Pin
leppie30-Mar-04 8:50
leppie30-Mar-04 8:50 
AnswerRe: Is this a pointer operation ? Pin
Andy Wieberneit30-Mar-04 11:09
Andy Wieberneit30-Mar-04 11:09 
AnswerRe: Is this a pointer operation ? Pin
Bryan White31-Mar-04 9:01
Bryan White31-Mar-04 9:01 
GeneralC# time to C++ time_t Pin
goodpilot30-Mar-04 8:22
goodpilot30-Mar-04 8:22 
GeneralRe: C# time to C++ time_t Pin
Heath Stewart30-Mar-04 9:31
protectorHeath Stewart30-Mar-04 9:31 
GeneralRe: C# time to C++ time_t Pin
goodpilot30-Mar-04 10:19
goodpilot30-Mar-04 10:19 
GeneralRe: C# time to C++ time_t Pin
Bryan White31-Mar-04 9:11
Bryan White31-Mar-04 9:11 

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.