12.3 When I add a destructor to a class, why isn't it hit when my instantiated object goes out of scope?


Your managed code doesn't have a destructor, just a finalizer. The difference is a destructor (as in C++) fires immediately when an object goes out of scope, but a finalizer is run when the CLR's garbage collector (GC) gets to your object. It's not deterministic when this will occur, but it's very unlikely to occur right after the object goes out of scope. It will happen at a later time, however.

(from sburke_online@microsoft..nospam..com on microsoft.public.dotnet.framework.windowsforms)

© 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap