public void WillCallBackAtSetInterval()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(new TimerCallback(CallbackMethod), 100);
     Thread.Sleep(1100);
     timer.StopPolling();
     Assert.IsTrue((counter >= 9) && (counter <= 12));
 }
Example #2
0
        public void WillCallBackAtSetInterval()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(new TimerCallback(CallbackMethod), 100);
            Thread.Sleep(1100);
            timer.StopPolling();
            Assert.IsTrue((counter >= 9) && (counter <= 12));
        }
        public void CanStopPolling()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer(100);

            timer.StartPolling(new TimerCallback(CallbackMethod));
            Thread.Sleep(1100);
            timer.StopPolling();
            Thread.Sleep(250);
            Assert.IsTrue((counter >= 9) && (counter <= 12));
        }
Example #4
0
        public CacheManager BuildCacheManager(
            string cacheManagerName,
            IBackingStore backingStore,
            int maximumElementsInCacheBeforeScavenging,
            int numberToRemoveWhenScavenging,
            int expirationPollFrequencyInSeconds,
            CachingInstrumentationProvider instrumentationProvider)
        {
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(maximumElementsInCacheBeforeScavenging);
            Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);
            ExpirationPollTimer timer          = new ExpirationPollTimer();
            ExpirationTask      expirationTask = CreateExpirationTask(cache, instrumentationProvider);
            ScavengerTask       scavengerTask  = new ScavengerTask(numberToRemoveWhenScavenging, scavengingPolicy, cache, instrumentationProvider);
            BackgroundScheduler scheduler      = new BackgroundScheduler(expirationTask, scavengerTask, instrumentationProvider);

            cache.Initialize(scheduler);
            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), expirationPollFrequencyInSeconds * 1000);
            return(new CacheManager(cache, scheduler, timer));
        }
 public void StartingWithZeroPollTimeThrowsException()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(new TimerCallback(CallbackMethod), 0);
 }
 public void StartingWithNullCallbackThrowsException()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(null, 100);
 }
Example #7
0
        public void StartingWithZeroPollTimeThrowsException()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(new TimerCallback(CallbackMethod), 0);
        }
Example #8
0
        public void StartingWithNullCallbackThrowsException()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(null, 100);
        }