CacheDependency.NotifyDependencyChanged(Object, EventArgs) 메서드

정의

파생 CacheDependency 클래스에 나타나는 종속성이 변경되었음을 기본 CacheDependency 개체에 알립니다.

protected:
 void NotifyDependencyChanged(System::Object ^ sender, EventArgs ^ e);
protected void NotifyDependencyChanged (object sender, EventArgs e);
member this.NotifyDependencyChanged : obj * EventArgs -> unit
Protected Sub NotifyDependencyChanged (sender As Object, e As EventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
EventArgs

이벤트 데이터가 포함된 EventArgs 개체입니다.

예제

다음 코드 예제에서는 클래스에서 상속되는 클래스를 CacheDependency 보여 줍니다. 이 메서드는 메서드를 사용하여 SetUtcLastModified 종속성이 수정된 시간을 변경한 다음 메서드를 호출하는 공용 ResetDependency메서드를 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

설명

클래스에서 파생되는 모든 클래스는 이 메서드를 CacheDependency 구현해야 합니다.

클래스에서 CacheDependency 파생되는 경우 재정의하지 않은 메서드 또는 속성의 기본 기능을 사용합니다. 파생 클래스의 인스턴스를 만들 때 캐시된 항목을 종속화하려는 파일, 캐시 키, 데이터베이스 테이블 또는 기타 임의 개체를 나타냅니다. 종속성 항목이 변경되면 이 메서드는 항목이 변경되었음을 클래스의 CacheDependency 기본 기능에 알리므로 해당 값 HasChangedUtcLastModified 속성을 업데이트할 수 있습니다.

적용 대상

추가 정보