Export (0) Print
Expand All

CacheDependency.SetUtcLastModified Method

Marks the time when a dependency last changed.

Namespace:  System.Web.Caching
Assembly:  System.Web (in System.Web.dll)

protected void SetUtcLastModified(
	DateTime utcLastModified


Type: System.DateTime

The time when the dependency last changed.

The following code example shows a class that inherits from the CacheDependency class. It creates a public method, ResetDependency, that uses the SetUtcLastModified method to change the time at which the dependency was modified, and then calls the NotifyDependencyChanged method.

' Declare the class. 
Public Class CustomCacheDependency 
   Inherits CacheDependency

     ' Constructor with no arguments  
     ' provided by CacheDependency class. 
     Public Sub New()
     End Sub ' New 

     ' 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 
           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              
           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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

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.

© 2014 Microsoft