CacheDependency.SetUtcLastModified(DateTime) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Marque l'heure de la dernière modification d'une dépendance.
protected:
void SetUtcLastModified(DateTime utcLastModified);
protected void SetUtcLastModified (DateTime utcLastModified);
member this.SetUtcLastModified : DateTime -> unit
Protected Sub SetUtcLastModified (utcLastModified As DateTime)
Paramètres
- utcLastModified
- DateTime
Heure de la dernière modification de la dépendance.
Exemples
L’exemple de code suivant montre une classe qui hérite de la CacheDependency classe . Il crée une méthode publique, ResetDependency
, qui utilise la SetUtcLastModified méthode pour modifier l’heure à laquelle la dépendance a été modifiée, puis appelle la NotifyDependencyChanged méthode.
' 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