Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public partial class SelectForm : BasePage,IDisposable
{
C#
public override void Dispose()
{
    Dispose(true);
    GC.SuppressFinalize(this);
}


C#
protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            #region Objects which are getting disposed
            if (_fieldControlHash != null)
            {
                _fieldControlHash = null;
            }
            if (_log != null)
            {
                _log = null;
            }
            if (_tLogic != null)
            {
                _tLogic = null;
            }
            if (_curTrans != null)
            {
                _curTrans=null;
            }
            if (_curUser != null)
            {
                _curUser=null;
            }
            if (_dynpop != null)
            {
                _dynpop = null;
            }
            //if (_environ != null)
            //{
            //    _environ = null;
            //}
            if (conGenGlobal != null)
            {
                conGenGlobal = null;
            }
            if (_CMSNotesLogic != null)
            {
                _CMSNotesLogic = null;
            }
            if (el != null)
            {
                el = null;
            }
            if (elog != null)
            {
                elog = null;
            }
            if (_mlogger != null)
            {
                _mlogger = null;
            }
            if (_mlog != null)
            {
                _mlog = null;
            }

            #endregion
        }
        disposed = true;
    }
}



}
Posted
Comments
db7uk 15-Jun-12 14:34pm    
um what is the question? what have you tried?

1 solution

You only need to implement IDisposable if you need to dispose of resources. Generally, if you are using a class that implements IDisposible, you need to ensure that the class's Dispose method is executed when you are finished using the class. This can be done by using the using statement, or by calling Dispose in the finally part of a try...catch...finally. Otherwise you should implement IDisposable, and ensure that the Disposable resource is disposed of. You also need to ensure that you call the Dispose method when finished with the class, otherwise there is no point. You can ensure that a class's Dispose method is called by doin what was stated above. You can also create cases where you are managing resources that do not have a disposable, but that is rare in business applications.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900