Type DISPOSE method should release all resources it owns. It should also release all the resources owned by the base type by calling its parent type DISPOSE method.
Dispose method should call the object it disposed
Gc.suppressFinalize method
. If the object is currently in the termination queue, GC.SuppressFinalize prevents its Finalize method from being called. Execute the Finalize method to greatly lose performance. If your Dispose method has completed the work of the cleaning object, the garbage collector does not have to call the Finalize method of the object.
Dispose (BOOL Disposing) is performed in two distinctive programs. If "Disposal" is equal to "true", the method has been directly called or indirectly called by the user's code, and can be disposed of managed resources and unmanaged resources. If "Disposal" is equal to "false", the method has been called inside the terminator from the terminator and can only dispose of unmanaged resources.
The Finalize method or descent function provided by the base class acts as a protective measures in the absence of invoking dispose. The Finalize method calls the DISPOSE method with parameters while passing "false".
Public class baseresource: idisposable {// Unmanaged Resource Private INTPTR HANDLE; // Managed Resource Private Component Components; // Track WHETER DISPOSE HAS BEEN CALLED. private bool disposed = false