0
Reply

Dispose

Ricardo Sousa

Ricardo Sousa

May 31 2009 9:37 PM
2.5k
Hello;
    I am trying to adapt a class to work with just finished that I am not able to solve the problem.
    My question is how to identify the handle to close / / CloseHandle (handle).
    My problem is that I am not able to adapt the following code.
for (Int32 i = 0; i < temp_items.Count; i++)
{
        string conj_itens = temp_itens[i].ToString();
         ContarSuporte cs= new ContarSuporte(matriz_bin,strExpr);
 _cont = cs.Suporte;
      If (_cont>100)
   {
     list.add(conj_itens);
   }
          
}
 
   public class ContarSuporte: IDisposable
    {
        private int _cont;
        private bool disposed = false;
        private IntPtr handle;
      
        public ContarSuporte()
        {
        }

       public ContarSuporte(DataTable matriz_binaria, string strExpr)
        {
            int c = matriz_binaria.Rows.Count;
            this._cont = (int)(matriz_binaria.Compute("COUNT(TID)", strExpr));
        }
        ~ContarSuporte()
         {
 
             Dispose(false);
               
        }
        public void Dispose()
        {
            //GC.Collect();
            Dispose(true);
            GC.SuppressFinalize(this);
            // GC.Collect();
        }

        private void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    //this.Dispose();
                }
                //CloseHandle(handle);
                handle = IntPtr.Zero;
               
            }
            disposed = true;
        }

        public int  Suporte
        {
            get
            {
                return _cont;
            }
            set
            {
                _cont =value;
            }
        }