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

C#

 
AnswerRe: Using large lookup table Pin
ShermansLagoon11-Feb-07 19:56
ShermansLagoon11-Feb-07 19:56 
GeneralRe: Using large lookup table Pin
AndrusM11-Feb-07 22:40
AndrusM11-Feb-07 22:40 
QuestionProper object disposal... Pin
Shy Agam11-Feb-07 9:12
Shy Agam11-Feb-07 9:12 
AnswerRe: Proper object disposal... Pin
Christian Graus11-Feb-07 10:16
protectorChristian Graus11-Feb-07 10:16 
GeneralRe: Proper object disposal... Pin
Shy Agam11-Feb-07 10:54
Shy Agam11-Feb-07 10:54 
GeneralRe: Proper object disposal... Pin
Christian Graus11-Feb-07 11:07
protectorChristian Graus11-Feb-07 11:07 
GeneralRe: Proper object disposal... Pin
Shy Agam11-Feb-07 12:01
Shy Agam11-Feb-07 12:01 
GeneralRe: Proper object disposal... Pin
Christian Graus11-Feb-07 12:12
protectorChristian Graus11-Feb-07 12:12 
shyagam wrote:
AFAIK the GC will not collect an object which is still referenced somewhere.


Correct. But, the issue is, you want to manage cleanup of some resources, right?

My point would be something like this

object C is the object that both A and B refer to.
object C contains a resource, which needs disposing of

object C keeps track of how many objects are referring to it

object A and B both refer to object C. So it has a reference count of 2.
object A calls Dispose and sets it's reference to null. object C internally does not dispose of the resource it holds, but it does drop it's counter to 1.
object B calls Dispose and sets it's reference to null. object C notices that it's reference count is now 0, so it calls Dispose on the resource in question
The GC cleans up the rest of object C, as nothing has references to it.


Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog

GeneralRe: Proper object disposal... Pin
Luc Pattyn11-Feb-07 12:45
sitebuilderLuc Pattyn11-Feb-07 12:45 
GeneralRe: Proper object disposal... Pin
Guffa11-Feb-07 12:35
Guffa11-Feb-07 12:35 
GeneralRe: Proper object disposal... Pin
Christian Graus11-Feb-07 12:45
protectorChristian Graus11-Feb-07 12:45 
GeneralRe: Proper object disposal... Pin
Guffa11-Feb-07 14:09
Guffa11-Feb-07 14:09 
GeneralRe: Proper object disposal... Pin
Christian Graus11-Feb-07 14:36
protectorChristian Graus11-Feb-07 14:36 
AnswerRe: Proper object disposal... Pin
Guffa11-Feb-07 12:25
Guffa11-Feb-07 12:25 
GeneralRe: Proper object disposal... Pin
Shy Agam11-Feb-07 23:04
Shy Agam11-Feb-07 23:04 
GeneralRe: Proper object disposal... Pin
Guffa12-Feb-07 4:39
Guffa12-Feb-07 4:39 
QuestionOpening other programs with C# Pin
Wolf9211-Feb-07 7:33
Wolf9211-Feb-07 7:33 
AnswerRe: Opening other programs with C# Pin
Stefan Troschuetz11-Feb-07 7:48
Stefan Troschuetz11-Feb-07 7:48 
QuestionConecting to database-C# Pin
mrkeivan11-Feb-07 7:23
mrkeivan11-Feb-07 7:23 
AnswerRe: Conecting to database-C# Pin
Mike Hankey11-Feb-07 7:57
mveMike Hankey11-Feb-07 7:57 
GeneralRe: Conecting to database-C# Pin
mrkeivan11-Feb-07 8:43
mrkeivan11-Feb-07 8:43 
GeneralRe: Conecting to database-C# Pin
Mike Hankey11-Feb-07 9:03
mveMike Hankey11-Feb-07 9:03 
AnswerRe: Conecting to database-C# Pin
Guffa11-Feb-07 8:55
Guffa11-Feb-07 8:55 
GeneralRe: Conecting to database-C# Pin
mrkeivan11-Feb-07 10:18
mrkeivan11-Feb-07 10:18 
AnswerRe: Conecting to database-C# Pin
Guffa11-Feb-07 11:20
Guffa11-Feb-07 11:20 

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.