共用方式為


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 類別。 它會建立公用方法 ,這個方法 ResetDependencySetUtcLastModified 使用 方法來變更修改相依性的時間,然後呼叫 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

適用於

另請參閱