ChangeMonitor.HasChanged Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value that indicates that the state that is monitored by the ChangeMonitor class has changed.
public:
property bool HasChanged { bool get(); };
public bool HasChanged { get; }
member this.HasChanged : bool
Public ReadOnly Property HasChanged As Boolean
Property Value
true
if the state that is monitored by the ChangeMonitor instance has changed; otherwise, false
.
Remarks
You can check the value of this property in a derived ChangeMonitor class to see whether a dependency has changed.
The value is set to true
when a dependency change occurs (that is, when the OnChanged method is called). After the OnChanged method is called by the derived class, the value of the HasChanged property will be true
, regardless of whether a OnChangedCallback instance has been notified by a call to the NotifyOnChanged method.
Note
Callers can check the HasChanged property to see whether a dependency has changed. However, in a multi-threaded environment, a simpler and more maintainable approach is to insert data into a cache implementation without checking the HasChanged property. Cache implementations must check the HasChanged property for you and must not perform an insert or set operation if one or more associated dependencies have already changed.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈