Condividi tramite


CacheDependency.DependencyDispose Metodo

Definizione

Rilascia le risorse utilizzate dalla classe CacheDependency e tutte le classi che derivano da CacheDependency.

protected:
 virtual void DependencyDispose();
protected virtual void DependencyDispose ();
abstract member DependencyDispose : unit -> unit
override this.DependencyDispose : unit -> unit
Protected Overridable Sub DependencyDispose ()

Esempio

Nell'esempio di codice seguente viene illustrata una classe che eredita dalla classe e esegue l'override del CacheDependencyDependencyDispose metodo. Quando questo metodo viene chiamato, imposta una proprietà booleana personalizzata denominata Disposed su true.

' 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

Commenti

Qualsiasi classe derivata dalla CacheDependency classe è necessaria per implementare questo metodo per pulire le risorse usate dalla classe derivata.

Si applica a

Vedi anche