disposablebasetype.cs

来自「BugNET is an issue tracking and project 」· CS 代码 · 共 52 行

CS
52
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace BugNET.Providers.ResourceProviders
{
    public class DisposableBaseType: IDisposable
    {
        private bool m_Disposed;
        protected bool Disposed
        {
           get
           {
                lock(this)
                {
                    return m_Disposed;
                }
            }
        }

    #region IDisposable Members

        public void Dispose()
        {
            lock (this)
            {
                if (m_Disposed == false)
                {
                    Cleanup();
                    m_Disposed = true;

                    GC.SuppressFinalize(this);
                }
            }
        }

        #endregion

        protected virtual void Cleanup()
        {
            // override to provide cleanup
        } 

        ~DisposableBaseType()   
        {
            Cleanup();
        } 

    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?