ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconimplementingdisposemethod.htm

解决方案 »

  1.   

    名字
    ~ClassName方法
    把使用到的对象NULL了,数据库连接关闭了,等等的收尾操作差不多了吧?
      

  2.   

    public class Test : IDisposable
    {
    ~Test()
    {
    this.Dispose(false);
    }

    public void Dispose()
    {
    this.Dispose(true);
    //remove this object from the finalization queue
    GC.SuppressFinalize(this);
    }
    protected void Dispose(bool disposeCalledDirectly)
    {
    if( disposeCalledDirectly )
    {
    //clean up managed resources here
    }
    //cleanup unmanaged resources here 
    }
    }