This documentation is archived and is not being maintained.

ChangeMonitor.Dispose Method (Boolean)

Releases all managed and unmanaged resources and any references to the ChangeMonitor instance. This overload must be implemented by derived change-monitor classes.

Namespace:  System.Runtime.Caching
Assembly:  System.Runtime.Caching (in System.Runtime.Caching.dll)

protected abstract void Dispose(
	bool disposing


Type: System.Boolean
true to release managed and unmanaged resources and any references to a ChangeMonitor instance; false to release only unmanaged resources. When false is passed, the Dispose method is called by a finalizer thread and any external managed references are likely no longer valid because they have already been garbage collected.

When the value of disposing value is true, all managed and unmanaged resources are disposed and any references to this object are released so that the derived change-monitor instance can be garbage collected. It is guaranteed that the base Dispose method will invoke the implemented Dispose method only one time.

Notes to Implementers

A change monitor must implement the Dispose overload to release all managed and unmanaged resources when the value of disposing is true. The Dispose method overload that has a disposing value of true is called only one time, namely, when the instance is disposed for the first time. A change monitor must not call the Dispose overload directly. A derived change monitor can call the public parameter-less Dispose method on the base ChangeMonitor class.

Alternatively, a change monitor can implement a finalizer method. In that case, the finalizer can invoke the Dispose method and pass it a disposing value of false. However, this is usually unnecessary. Monitoring for dependency changes is typically performed by a service that maintains a reference to the change-monitor instance. The reference prevents the instance from being garbage collected, and therefore makes a finalizer method unnecessary. To avoid memory leaks, when a dependency changes, the OnChanged method disposes the change-monitor instance (unless initialization has not finished).

.NET Framework

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.