ChangeMonitor 构造函数

定义

初始化 ChangeMonitor 类的新实例。Initializes a new instance of the ChangeMonitor class. 从派生类中的构造函数调用此构造函数以初始化基类。This constructor is called from constructors in derived classes to initialize the base class.

protected:
 ChangeMonitor();
protected ChangeMonitor ();
Protected Sub New ()

注解

ChangeMonitor类具有无参数的构造函数。The ChangeMonitor class has a parameterless constructor. 但是,从基类继承 ChangeMonitor 并定义自定义更改监视行为的类必须在构造函数中执行初始化。However, classes that inherit from the base ChangeMonitor class and define custom change-monitoring behavior must perform initialization in the constructor. 有关详细信息,请参阅对继承者的说明部分。For more information, see the Notes for Inheritors section.

继承者说明

派生类的构造函数必须设置 UniqueId 属性,开始监视,然后在 InitializationComplete() 返回类之前调用类。The constructor of a derived class must set the UniqueId property, begin monitoring, and call the InitializationComplete() class before it returns. 如果在初始化完成之前依赖项发生了更改 (例如,如果缓存) 中找不到依赖缓存键,则构造函数必须在调用 OnChanged(Object) 方法之前调用方法 InitializationComplete()If a dependency changes before initialization is complete (for example, if a dependent cache key is not found in the cache), the constructor must call the OnChanged(Object) method before it calls the InitializationComplete() method. 在这种情况下,构造函数只能 Dispose() 在调用方法后调用方法 InitializationComplete() ,因为 Dispose() 如果初始化未完成,则该方法将引发异常。In this case, constructor can call the Dispose() method only after the InitializationComplete() method is called, because the Dispose() method throws an exception if initialization is not completed.

适用于