Click here to Skip to main content
15,883,623 members
Home / Discussions / C#
   

C#

 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
JoeRip30-Jul-08 21:44
JoeRip30-Jul-08 21:44 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Frank Horn31-Jul-08 3:24
Frank Horn31-Jul-08 3:24 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Christian Graus30-Jul-08 23:55
protectorChristian Graus30-Jul-08 23:55 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Scott Dorman2-Aug-08 15:26
professionalScott Dorman2-Aug-08 15:26 
AnswerRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Alan Balkany31-Jul-08 3:23
Alan Balkany31-Jul-08 3:23 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
JoeRip31-Jul-08 3:26
JoeRip31-Jul-08 3:26 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Alan Balkany31-Jul-08 4:17
Alan Balkany31-Jul-08 4:17 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Scott Dorman2-Aug-08 15:32
professionalScott Dorman2-Aug-08 15:32 
JoeRip wrote:
The point is, unless my client (who created my object) calls Garbage Collection explicitly, my destructor won't be called in a timely fashion.


That's one of the drawbacks to a garbage collected runtime. The idea is that you implement the IDispsoable interface (actually, the Dispose pattern[^]) which tells the GC how to release your unmanaged memory and signals to the caller (client) that they should call Dispose() when they are done using your object. If you need a stronger assurance that your resources get cleaned up then you can implement a finalizer (see the above reference article for issues/concerns about implementing finalizers) and if you absolutely need to guarantee the finalizer gets called you need use a "critical finalizable object" and inherit from CriticalFinalizerObject.

Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Scott Dorman2-Aug-08 15:23
professionalScott Dorman2-Aug-08 15:23 
QuestionCannot debug c# dll Pin
manju#12330-Jul-08 20:36
manju#12330-Jul-08 20:36 
AnswerRe: Cannot debug c# dll Pin
Christian Graus30-Jul-08 20:59
protectorChristian Graus30-Jul-08 20:59 
Questionhow many rows and columns are hidden in an excel sheet Pin
Mogaambo30-Jul-08 20:20
Mogaambo30-Jul-08 20:20 
Question'switch' statement efficiency in C# Pin
scody30-Jul-08 19:50
scody30-Jul-08 19:50 
AnswerRe: 'switch' statement efficiency in C# Pin
Christian Graus30-Jul-08 20:07
protectorChristian Graus30-Jul-08 20:07 
GeneralRe: 'switch' statement efficiency in C# Pin
scody30-Jul-08 21:12
scody30-Jul-08 21:12 
AnswerRe: 'switch' statement efficiency in C# Pin
Guffa30-Jul-08 22:02
Guffa30-Jul-08 22:02 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie30-Jul-08 22:52
leppie30-Jul-08 22:52 
GeneralRe: 'switch' statement efficiency in C# Pin
Christian Graus30-Jul-08 23:57
protectorChristian Graus30-Jul-08 23:57 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 0:14
leppie31-Jul-08 0:14 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 1:57
Guffa31-Jul-08 1:57 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 2:17
leppie31-Jul-08 2:17 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 2:58
Guffa31-Jul-08 2:58 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 5:46
leppie31-Jul-08 5:46 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie30-Jul-08 22:51
leppie30-Jul-08 22:51 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 1:18
Guffa31-Jul-08 1:18 

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.