Home
Browse all 647 examples
Download all 647 examples
Download sample chapters
Reviews
Errata
Acknowledgments
Links on .NET
Paradoxal Press

Buy directly from Paradoxal Press at $33.99 (Save 43%)



Category: Programming
Level: Beginner to seasoned
900 pages
ISBN-10 097661322-0
ISBN-13 978-097661322-0
$59.99 USA
$79.99 CANADA


Listing 23-58 extracted from chapter ASP.NET 2


Listing 23-57<     > Listing 23-59


This listing can be compiled with the command line:
csc.exe /target:library Example_23_58.cs
Errors: 0 Warnings: 0


Example_23_58.cs
using System;
using System.Web.Caching;
using System.Timers;
public class CustomCacheDependency : CacheDependency {
   private Timer m_Timer = new Timer();
   private string m_ResourceId;
   public CustomCacheDependencyint pollIntervalSec, string resourceId ) {
      m_ResourceId = resourceId;
      m_Timer.Interval = pollIntervalSec * 1000;
      m_Timer.Elapsed += this.CheckDependencyHandler;
      m_Timer.Start();
   }
   private void CheckDependencyHandler(object sender, ElapsedEventArgs e) {
      // Here, insert the code that detects any change on the
      // state of the resource indexed by m_ResourceId.
      bool resourceHasChanged = false;
      if ( resourceHasChanged )
         NotifyDependencyChanged(thisEventArgs.Empty);
   }
   protected override void DependencyDispose() {
      m_Timer.Stop();
   }
}	
Copyright Patrick Smacchia 2006 2007