E
Eric Cadwell
A handy piece of code...
Put this in your Dipose() methods and it will do all your clean up for.
Just need to add support for unregistering events and all our memory leaks
will be gone!
public void Disposer()
{
Type type = this.GetType();
if (type != null)
{
foreach(FieldInfo fi in type.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance))
{
object field = fi.GetValue(this);
if (field is IDisposable)
{
((IDisposable)field).Dispose();
Console.WriteLine("disposed field:" + fi.Name);
}
}
}
}
Eric Cadwell
http://www.origincontrols.com
Put this in your Dipose() methods and it will do all your clean up for.
Just need to add support for unregistering events and all our memory leaks
will be gone!
public void Disposer()
{
Type type = this.GetType();
if (type != null)
{
foreach(FieldInfo fi in type.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance))
{
object field = fi.GetValue(this);
if (field is IDisposable)
{
((IDisposable)field).Dispose();
Console.WriteLine("disposed field:" + fi.Name);
}
}
}
}
Eric Cadwell
http://www.origincontrols.com