Click here to Skip to main content
15,890,185 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: What makes a class IDisposable? Pin
led mike13-Aug-07 6:28
led mike13-Aug-07 6:28 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 6:46
mid=574113-Aug-07 6:46 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 6:29
iddqd51513-Aug-07 6:29 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 6:45
mid=574113-Aug-07 6:45 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 7:32
iddqd51513-Aug-07 7:32 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 7:53
mid=574113-Aug-07 7:53 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 8:09
iddqd51513-Aug-07 8:09 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery13-Aug-07 8:44
Mark Salsbery13-Aug-07 8:44 
I may be reading your comments wrong, but did you state a C++ ref class destructor is a finalizer?

That's not the case.  The destructor maps to Dispose() and a finalizer must be explicitly added.

Destructors do not get called if you allocate an object on the managed heap and never explicitly
delete it.  The finalizer, however will be called when the handle no longer has any references to it
and the GC gets around to cleaning it up.  That's why native objects should be freed in a finalizer,
not a destructor (although the destructor should call the finalizer - the compiler takes care of
SuppressFinalize). 

Having to explicitly delete objects would be counterintuitive, as Michael originally stated. 
Being able to (deterministically) using the familiar C++ syntax, however, is a nice, powerful
feature.

Note I'm only referring to C++ - I'll make no comments about C# except for the related Dispose/Finalize
pattern of CLR. Smile | :)

Cheers,
Mark



Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 8:55
iddqd51513-Aug-07 8:55 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery13-Aug-07 9:35
Mark Salsbery13-Aug-07 9:35 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 8:48
mid=574113-Aug-07 8:48 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 9:03
iddqd51513-Aug-07 9:03 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 9:15
mid=574113-Aug-07 9:15 
GeneralRe: What makes a class IDisposable? [modified] Pin
iddqd51513-Aug-07 9:19
iddqd51513-Aug-07 9:19 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 9:30
mid=574113-Aug-07 9:30 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 9:36
iddqd51513-Aug-07 9:36 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery13-Aug-07 9:38
Mark Salsbery13-Aug-07 9:38 
GeneralRe: What makes a class IDisposable? [modified] Pin
iddqd51513-Aug-07 9:43
iddqd51513-Aug-07 9:43 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery13-Aug-07 9:51
Mark Salsbery13-Aug-07 9:51 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 9:55
iddqd51513-Aug-07 9:55 
GeneralRe: What makes a class IDisposable? Pin
Luc Pattyn13-Aug-07 7:00
sitebuilderLuc Pattyn13-Aug-07 7:00 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery12-Aug-07 10:06
Mark Salsbery12-Aug-07 10:06 
GeneralRe: What makes a class IDisposable? Pin
George L. Jackson14-Aug-07 3:48
George L. Jackson14-Aug-07 3:48 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery14-Aug-07 5:10
Mark Salsbery14-Aug-07 5:10 
GeneralRe: What makes a class IDisposable? Pin
Mark Salsbery13-Aug-07 4:53
Mark Salsbery13-Aug-07 4:53 

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.