How to Dispose myClass with Garbage Collecter C#
- by Ibrahim AKGUN
Hi,
I have a class and got a method that doin so many things in memory and need to be disposed when its jobs done.But i have looked for MSDN for solution.There is an example thats not solved my problem.When my Class is instanced and run this method my memory is getting bigger and bigger.How can i Dispose it when its job done ?
Here is my CODES ;
class Deneme
{
public Deneme()
{ }
~Deneme()
{
GC.Collect();
GC.SuppressFinalize(this);
}
public void TestMetodu()
{
System.Windows.Forms.MessageBox.Show("Test");
// This is my method that doing big jobs :)
}
}
Deneme CCCX = new Deneme();
CCCX.TestMetodu();
CCCX = null;
So i cant dispose it with this.