Roger,
Generally when using a type for the first time I read the documentation for
that type to see if there are "special" requirements such as calling Dispose
on it.
A good general (very general) rule of thumb to follow is if it implements
IDisposable, call Dispose. The "problem" with this rule is if you inherit
from System.ComponentModel.Component, then you have implemented IDisposable
& Dispose may or may not be needed. Of course calling Dispose when it is not
needed is "better" then not calling it when it is needed!!
Note: implementing IComponent directly, rather then inheriting from
Component would allow you to exclude the IDisposable itself!
Hope this helps
Jay
"Roger" <ro***@pcsrevenuecontrol.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Dim gr As Graphics = Me.CreateGraphics()
Dim sz As Size
Try
sz = gr.MeasureString(txtMyTextBox.Text,me.Font)
Finally
gr.Dispose()
End Try
Ok, how to know if it is managed or not,
that is Framework will garbage collect,
or it must be disposed in code manually?
Thanks,
Roger