CacheDependency.SetUtcLastModified(DateTime) 方法

定义

标记依赖项的上次更改时间。

protected:
 void SetUtcLastModified(DateTime utcLastModified);
protected void SetUtcLastModified (DateTime utcLastModified);
member this.SetUtcLastModified : DateTime -> unit
Protected Sub SetUtcLastModified (utcLastModified As DateTime)

参数

utcLastModified
DateTime

依赖项的上次更改时间。

示例

下面的代码示例演示从类继承的 CacheDependency 类。 它创建一个公共方法, ResetDependency该方法使用 SetUtcLastModified 该方法更改修改依赖项的时间,然后调用 NotifyDependencyChanged 该方法。

' Declare the class.
Public Class CustomCacheDependency 
   Inherits CacheDependency

     ' Constructor with no arguments 
     ' provided by CacheDependency class.
     Public Sub New()
     End Sub
   
     ' Declare a Boolean field named disposedValue.
     ' This will be used by Disposed property.
     Private disposedValue As Boolean                
     
     ' Create accessors for the Disposed property.
     Public Property Disposed As Boolean
       Get
           Return disposedValue
       End Get
       Set (ByVal value As Boolean)
           disposedValue = value
       End Set
     End Property
     
     ' Create a public method that sets the latest
     ' changed time of the CustomCacheDependency
     ' and notifies the underlying CacheDependency that the 
     ' dependency has changed, even though the HasChanged
     ' property is false.
     Public Sub ResetDependency()
        If Me.HasChanged = False              
           SetUtcLastModified(DateTime.MinValue)
           NotifyDependencyChanged(Me, EventArgs.Empty)
        End If
     End Sub
     
     ' Overrides the DependencyDispose method to set the
     ' Disposed proerty to true. This method automatically
     ' notifies the underlying CacheDependency object to 
     ' release any resources associated with this class. 
     Protected Overrides Sub DependencyDispose()
        Disposed = True
     End Sub
     
     
 End Class

适用于

另请参阅