Uncle Gizmo Posted May 25, 2004 Posted May 25, 2004 This code appeared at the end of my code block. Where did it come from? Can I delete it? Protected Overrides Sub Finalize() MyBase.Finalize() End Sub Quote
Administrators PlausiblyDamp Posted May 25, 2004 Administrators Posted May 25, 2004 Depends on what the res of your code is. Was this code a form, control etc? what class is it inheriting from? All it does is call the base class' clean up methods when the class is ready to be garbage collected - so it depends on what the class is / base class is. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
JABE Posted May 25, 2004 Posted May 25, 2004 If this was auto-generated by VS.NET, then leave it as it is. If not, then ask the programmer who put it in. Quote
Uncle Gizmo Posted May 25, 2004 Author Posted May 25, 2004 I suspect it appeared when I added this: Imports System.Math ' Need this to use Abs function But I don't know for sure... I'll leave it in for now. >>>>Auto generated by VS<<<< I did'nt know it did this, thanks for the info Quote
CattleRustler Posted May 25, 2004 Posted May 25, 2004 it's generated by vb.net If you select your form's Overides, then select Finalize although the "MyBase.Finalize()" shouldn't appear, just the outter def-end def. Maybe someone else who worked on this code placed it there Quote mod2software Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
Administrators PlausiblyDamp Posted May 25, 2004 Administrators Posted May 25, 2004 (edited) Imports system.Math wouldn't cause this to be added. A finalize method is use by the garbage collector to make sure non-managed resources get properly released when the object is no longer available. If the base class wraps any OS resource (file handle, window handle, memory mapped file etc.) then these resources are outside of .Net's control and cannot be garbage collected like a managed .Net object. If your class implements the Finalize method then the garbage collector knows that the class needs special handling and will call the Finalize method a part of the garbage collection process - you would provide clean-up code for your non-managed resources there. If the base class requires this then I would most definitely leave the auto generated code alone - deleting it could cause resource leaks and lead to general instability of the application. Edited March 16, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.