ChangeMonitor.Dispose Method ()
Releases all resources that are used by the current instance of the ChangeMonitor class.
Assembly: System.Runtime.Caching (in System.Runtime.Caching.dll)
Initialization is not complete in the derived change-monitor class that called the basemethod.
The Dispose method of derived classes only one time, the first time it is called. Subsequent calls to the method have no effect. After the method has been called, the IsDisposed property is set to true.method invokes the
Before an item is inserted into the cache, it is the caller's responsibility to dispose of a ChangeMonitor instance.
After an item and its associated ChangeMonitor instances are passed to a cache, the caller must not dispose the dependency because when the Dispose method is called, the call is treated as if the dependency has changed. As a result, the OnChanged method is automatically invoked.
Taking these rules into consideration, the Dispose method must be called in one of the following ways:
Users must call themethod overload if they decide not to insert the derived change-monitor instance into a cache.
The cache implementation is responsible for calling theoverload if the implementation tries to insert the change-monitor instance into an object cache but the insertion fails. When the insertion attempt causes an exception, the cache implementation must dispose any associated dependencies.
If the cache entry is removed, the cache implementation must also dispose the dependency.
This automatic dispose during the event firing only occurs if the initialization of the ChangeMonitor instance previously completed.
When a derived change monitor's constructor calls the InitializationComplete method, if the state of the change monitor has already changed (that is, the state that is monitored has already changed when the constructor was still active) then InitializationComplete method will automatically dispose the change monitor.
Users should not call the OnChanged method is invoked. In that case, the cache entry is notified as if the dependency has changed.method. However, you cannot prevent users from calling the method. Therefore, if they do, the
To prevent derived classes from overridingmethod, the method is not an explicit interface implementation.
Available since 4.0