473,395 Members | 1,497 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,395 software developers and data experts.

Dispose...AGAIN

When using a Context Menu, I've added menuitems to the ContextMenu and have
the following questions:

If I delete a menuitem, do I have to use it's dispose method also?

If I use mycontextmenu.menuitems.Clear, does this dospose of the MenuItems
or do I have to still call the Dispose method on each item

If I use the ContextMenu.Dispose, does it call all the current MenuItems
Dispose method,

Really, I'm struggling with when to call dispose and when not to. It seems
a burden that M'soft put on the programmers that could have been avoided by a
bit smarter .Net Framework.
--
Dennis in Houston
Nov 21 '05 #1
2 1008
Dennis,

The GC clears all objects that have no reference anymore to it or cannot be
referenced from anypoint anymore.

This is done in three different generations.

You can read it in this document. (I am not so glad how they wrote disposing
in this document, know that unmanaged resources are not unmanaged objects.
Unmanaged resources are disposed by managed objects which implements
Idisposable).

The complete document.
http://msdn.microsoft.com/architectu...l/scalenet.asp

The GC in this document
http://msdn.microsoft.com/architectu...chapt05_topic9

I hope this helps?

Cor
Nov 21 '05 #2
Thanks Cor. I haven't seen this link before and looking at it, it will take
some time to read thru it. Although I understand what managed, unmangaged
means and what dispose vs Garbage collection means, I doubt if I'll ever
fully understand when to dispose of objects. Thanks again.

"Cor Ligthert" wrote:
Dennis,

The GC clears all objects that have no reference anymore to it or cannot be
referenced from anypoint anymore.

This is done in three different generations.

You can read it in this document. (I am not so glad how they wrote disposing
in this document, know that unmanaged resources are not unmanaged objects.
Unmanaged resources are disposed by managed objects which implements
Idisposable).

The complete document.
http://msdn.microsoft.com/architectu...l/scalenet.asp

The GC in this document
http://msdn.microsoft.com/architectu...chapt05_topic9

I hope this helps?

Cor

Nov 21 '05 #3

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

Similar topics

2
by: Nigel T | last post by:
Hi, I have a form containing controls, a timer, and the EventLog component. I also create some new instances of classes that do not implement idisposable I don't want to leave the tidying up to...
11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
14
by: qrli | last post by:
I used to think that all objects that implement IDisposable should be disposed. But I found 80% of the classes implement IDisposable. But when I looked into the samples, most objects are not...
9
by: Charles Law | last post by:
I have a form on which user controls are placed at runtime. When a control is added to the form a handler is added for an event that a high-level object raises, which must be handled by the new...
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...
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...
44
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.