CacheDependency.DependencyDispose メソッド

定義

CacheDependency クラス、および CacheDependency から派生したクラスが使用したリソースを解放します。Releases the resources used by the CacheDependency class and any classes that derive from CacheDependency.

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

次のコード例は、クラスを継承し、メソッドをオーバーライドするクラスを示して CacheDependency DependencyDispose います。The following code example shows a class that inherits from the CacheDependency class and overrides the DependencyDispose method. このメソッドが呼び出されると、という名前のカスタムのブール型プロパティがに設定され Disposed true ます。When this method is called, it sets a custom Boolean property named Disposed to 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

注釈

クラスから派生したクラス CacheDependency は、派生クラスが使用したリソースをクリーンアップするために、このメソッドを実装する必要があります。Any class that derives from the CacheDependency class is required to implement this method to clean up resources the derived class has used.

適用対象

こちらもご覧ください