Skip to main content

This version of the product is no longer supported, and this documentation is no longer updated regularly. See the latest version of this content.Opens in a new tab

Clean Up

You should add code to your project that ensures that the resources used by the CMP are freed when the application finishes with them. All .NET proxy objects as well as CacheConnection implement the Dispose method for this purpose.

For example, if your application implements a Dispose method, you should modify it so that it disposes of the connection to Caché as well as any .NET proxy objects.

Here is an example of a Dispose method for a .NET Windows Form. The code for disposing of the connection to Caché and any .NET proxy objects must be added manually. Visual Studio automatically generates the rest of the code.


protected override void Dispose(bool disposing)
{
  if (disposing && (components != null))
  {
    components.Dispose();
    //Clean up the database connection
    if (cnCache != null) cnCache.Dispose();
    //Clean up a proxy object
    if (proxyObj !=null) proxyObj.Dispose();
   }
  base.Dispose(disposing);
}      

In the example, cnCache represents a CacheConnection and proxyObj represents .NET proxy object.

FeedbackOpens in a new tab