This topic has not yet been rated - Rate this topic

ChangeMonitor.HasChanged Property

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

Namespace:  System.Runtime.Caching
Assembly:  System.Runtime.Caching (in System.Runtime.Caching.dll)
public bool HasChanged { get; }

Property Value

Type: System.Boolean
true if the state that is monitored by the ChangeMonitor instance has changed; otherwise, false.

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.

NoteNote

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.