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
mid=574112-Aug-07 7:58
mid=574112-Aug-07 7:58 
GeneralRe: What makes a class IDisposable? Pin
Luc Pattyn12-Aug-07 8:41
sitebuilderLuc Pattyn12-Aug-07 8:41 
GeneralRe: What makes a class IDisposable? [modified] Pin
mid=574112-Aug-07 9:00
mid=574112-Aug-07 9:00 
GeneralRe: What makes a class IDisposable? Pin
iddqd51513-Aug-07 6:06
iddqd51513-Aug-07 6:06 
GeneralRe: What makes a class IDisposable? Pin
mid=574113-Aug-07 6:15
mid=574113-Aug-07 6:15 
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 
oh right, wasn't paying close enough attention. And yes MS semantics are horribly confusing.

In that case, the C# ~Class1() is the finalizer. And by explicitly defining one you ensure that it is called by the garbage collector before the memory for an instance of the class is reclaimed. So although you're printing 'destructed' its actually the garbage collector calling the finalizer before memory is reclaimed. Its not a destructor that runs when the variable goes out of scope as you would get if it was a C++/CLI ref class with ~Class1() defined. And unlike destruction, finalization is nondeterministic and incurs a high performance cost for both allocation and deallocation. So you never want to write one unless your class contains unmanaged resources that won't be cleaned up by the garbage collector. In that case the finalizer will ensure the unmanaged stuff is cleaned up even if someone forgets to call delete or Dispose.
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 
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 

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.