Disposing the members that implement IDisposable.
Posted
by Amby
on Stack Overflow
See other posts from Stack Overflow
or by Amby
Published on 2010-06-11T12:25:28Z
Indexed on
2010/06/11
12:43 UTC
Read the original article
Hit count: 257
In my Dispose methods (like the one below), everytime i want to call someObj.Dispose() i also have a check for someObj!=null.
Is that because of bad design on my part? Is their a cleaner way to ascertain that Dispose of all the members (implementing IDisposable) being used in an object is called without having a risk of NullReference exception ?
protected void Dispose(bool disposing)
{
if (disposing)
{
if (_splitTradePopupManager != null)
{
_splitTradePopupManager.Dispose();
}
}
}
Thanks for your interest.
© Stack Overflow or respective owner