SIL.FieldWorks.Common.Controls.Persistence.Dispose C# (CSharp) Method

Dispose() protected method

Releases the resources used by Persistence
protected Dispose ( bool disposing ) : void
disposing bool
return void
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				if (m_parent != null)
				{
					if (m_parent is Form)
						((Form)m_parent).Closed -= new EventHandler(this.OnSaveSettings);
					else
						m_parent.HandleDestroyed -= new System.EventHandler(this.OnSaveSettings);
					m_parent.HandleCreated -= new System.EventHandler(this.OnLoadSettings);
					m_parent.Move -= new System.EventHandler(this.OnMoveResize);
					m_parent.Resize -= new System.EventHandler(this.OnMoveResize);
				}
			}
			m_parent = null;

			base.Dispose(disposing);

			m_isDisposed = true;
		}
		#endregion

Usage Example

Example #1
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        protected override void Dispose(bool fDisposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            base.Dispose(fDisposing);

            if (fDisposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_draftView != null)
                {
                    m_draftView.Dispose();
                }
                if (m_isNewCache && (m_cache != null))
                {
                    m_cache.Dispose();                     // Only if we made it.
                }
                if (m_Persistence != null)
                {
                    m_Persistence.Dispose();
                }
            }
            m_cache       = null;
            m_draftView   = null;
            m_styleSheet  = null;
            m_rootb       = null;
            m_Persistence = null;
        }