Editare

Partajați prin


ChangeMonitor Class

Definition

Provides a base class for a derived custom type that monitors changes in the state of the data which a cache item depends on.

public ref class ChangeMonitor abstract : IDisposable
public abstract class ChangeMonitor : IDisposable
type ChangeMonitor = class
    interface IDisposable
Public MustInherit Class ChangeMonitor
Implements IDisposable
Inheritance
ChangeMonitor
Derived
Implements

Remarks

The ChangeMonitor class is used as the base class for derived monitor classes that are specialized for particular cache implementations. A ChangeMonitor instance monitors changes in the state of data which a cache item depends on. For example, the item can be a file or data entity whose contents are cached. If the file or data entity is updated, the associated cache entry must be changed also. Common items that can be monitored include data entities (such as database fields, values, rows, or tables), another cache entry, and files and file attributes.

A dependency change is a change in the state of a dependency. In a typical cache implementation, after a ChangeMonitor instance notifies the cache that a dependency has changed, the cache performs the required action, such as invalidating the inserted cache entry.

Derived ChangeMonitor classes can be customized to monitor dependency changes for specific different data stores. For example, there are cache implementations for a file system, physical memory, or a database. The ChangeMonitor class examines changes that occur outside the cache, and then alerts the cache that changes have occurred.

The .NET Framework includes the following classes that derive from ChangeMonitor class:

Each of these classes works with different types of dependencies. For example, the derived FileChangeMonitor class monitors changes to a cache for file system data (files and folders) that the cache item depends on.

Notes to Implementers

If you create a custom cache implementation or a derived change monitor type, you must follow certain guidelines. The following list summarizes these guidelines. For more information, see the documentation for individual methods or properties.

Note: This automatic call to the dispose method during the event firing only occurs if the initialization of the ChangeMonitor instance was 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 already changed when the constructor was still active) then the InitializationComplete() method will automatically dispose of the change monitor.

Constructors

ChangeMonitor()

Initializes a new instance of the ChangeMonitor class. This constructor is called from constructors in derived classes to initialize the base class.

Properties

HasChanged

Gets a value that indicates that the state that is monitored by the ChangeMonitor class has changed.

IsDisposed

Gets a value that indicates that the derived instance of a ChangeMonitor class is disposed.

UniqueId

Gets a value that represents the ChangeMonitor class instance.

Methods

Dispose()

Releases all resources that are used by the current instance of the ChangeMonitor class.

Dispose(Boolean)

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

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializationComplete()

Called from the constructor of derived classes to indicate that initialization is finished.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
NotifyOnChanged(OnChangedCallback)

Called by Cache implementers to register a callback and notify an ObjectCache instance through the OnChangedCallback delegate when a dependency has changed.

OnChanged(Object)

Called by derived classes to raise the event when a dependency changes.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Thread Safety

This type is thread safe.

See also