I have a class with a public font property, I do like that
Font font;
public Font Font
{
get
{
if(font == null)
using(Form f = new Form()) // get default font !
font = new Font(f.Font.Name, f.Size, FontStyle.Regular);
return font;
}
set
{
if(font != null)
font.Dispose();
font = value;
}
}
public void Dispose()
{
Font = null;
}
I don't not call GC.SuppressFinalizer(this); as I don't feel the need for
Finalizer as:
1. I don't have unmanaged resource
2. having finalizer makes my object life longers, which I don't want
my problem is:
what if in my master class I have on font object and pass it to all this
'label' ?
if I change the font for one later I destroy all as they all use the same
(disposed) font ?
so I could not use dispose the font when I change it so I have to write
complex code to know if it's still in use in the main class ?
well I'm a bit lost.. I need guidance on the proper scenarii .....

Signature
ihookdb
Get your data mobile
http://www.ihookdb.com
Chad Z. Hower aka Kudzu - 19 May 2004 07:38 GMT
"Lloyd Dupont" <net.galador@ld> wrote in news:eozRJfUPEHA.1644
@TK2MSFTNGP09.phx.gbl:
> my problem is:
> what if in my master class I have on font object and pass it to all this
[quoted text clipped - 4 lines]
> complex code to know if it's still in use in the main class ?
> well I'm a bit lost.. I need guidance on the proper scenarii .....
You could add your own reference counting, but the problem you will have with
this code is that there is NO guarantee that Dispose will be called for each
instance.
What exactly are you tyring to do with your Font = null in the dispose?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/