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 示しています。 これにより、 ResetDependencyメソッドを使用 SetUtcLastModified して依存関係が変更された時刻を変更し、 メソッドを呼び出すパブリック メソッド が 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 派生する場合は、オーバーライドされていない任意のメソッドまたはプロパティの基本機能を使用します。 派生クラスのインスタンスを作成すると、キャッシュされた項目を依存させるファイル、キャッシュ キー、データベース テーブル、またはその他の任意のオブジェクトが表されます。 依存関係項目が変更されると、このメソッドは、 プロパティと UtcLastModified プロパティの値をCacheDependency更新できるように、項目が変更されたことをクラスの基本機能にHasChanged通知します。

適用対象

こちらもご覧ください