473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Dispose and Finalize - When to use

I have two questions;

1)When should one use Dispose on objects

2)Is the Finalize Overrides sub needed in classes and if so, when and why?

Thanks for any clarification on these two items.

--
Dennis in Houston
Nov 21 '05 #1
3 1176
Some guidelines on using dispose and finalize:
http://msdn.microsoft.com/library/de...izedispose.asp

A couple of blog posts on Dispose:
http://blogs.msdn.com/clyon/archive/...21/232445.aspx
http://blogs.msdn.com/clyon/archive/...23/233464.aspx

Articles on how GC handles objects with a finalized method (and more on GC):
http://msdn.microsoft.com/msdnmag/issues/1100/GCI/
http://msdn.microsoft.com/msdnmag/is...2/default.aspx
hope that helps..
Imran.

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
I have two questions;

1)When should one use Dispose on objects

2)Is the Finalize Overrides sub needed in classes and if so, when and why?

Thanks for any clarification on these two items.

--
Dennis in Houston

Nov 21 '05 #2
Thanks. I"ll read the links and see what I can understand.

"Imran Koradia" wrote:
Some guidelines on using dispose and finalize:
http://msdn.microsoft.com/library/de...izedispose.asp

A couple of blog posts on Dispose:
http://blogs.msdn.com/clyon/archive/...21/232445.aspx
http://blogs.msdn.com/clyon/archive/...23/233464.aspx

Articles on how GC handles objects with a finalized method (and more on GC):
http://msdn.microsoft.com/msdnmag/issues/1100/GCI/
http://msdn.microsoft.com/msdnmag/is...2/default.aspx
hope that helps..
Imran.

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
I have two questions;

1)When should one use Dispose on objects

2)Is the Finalize Overrides sub needed in classes and if so, when and why?

Thanks for any clarification on these two items.

--
Dennis in Houston


Nov 21 '05 #3
Dennis,

The most simple answers,

1)When should one use Dispose on objects
When it is written that you should
2)Is the Finalize Overrides sub needed in classes and if so, when and why?

The same answer as above, otherwise never.

I hope this helps?

Cor


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: celeong | last post by:
Hi, anybody can help me with this. I've created a singleton class, and now wants to add destructor to it. I know we can implement the IDisposable and also overrides the Finalize method (from...
4
by: RiteshDotNet | last post by:
..net Frame work 1. Dispose Method what it does ? A. who its call / when it calls ? B. Is it fire automatically ? c. When dispose method is call what it does ? D. Release a Object from memory or...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
4
by: Joe Abou Jaoude | last post by:
I m preparing to pass the 70-306 exam, so i downloaded Q & A from multiple sites. There's this question that really confuses me, coz i see that both answers A and C are both correct. Can anyone...
6
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged...
14
by: Jonas | last post by:
Hi! I'm developing the middletiers of an ASP.NET application in VB.NET. I've got a business logic layer in which I would like to perform auditing to a database. Instead of making an auditing...
156
by: Dennis | last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose method based on advice from this newsgroup. However, I'm not sure how to dispose of the following object that was created...
2
by: eBob.com | last post by:
I have a user control which creates an Excel spread sheet and badly needs Dispose/Finalize. I've read up on the subject in Balena and I think I understand what is going on. But the VS generated...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
4
by: BLUE | last post by:
I've read many articles including the one from Duff's blog but I've many doubts. public static myClass Instance { get { if (myClass.instance == null) myClass.instance = new myClass();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.