I'm trying to simulate the .NET 2.0 Database Cache Dependency stuff (well kind of, WAY simpler obviously). What I'm doing is running a little timer class as a static property of my global.asax.cs file...like so:
public static TimerClass timr = new TimerClass();
My actual timer class thing is really simple, it just adds items to a queue on each tick; in the actual app this will fire a simple stored procedure and only add certain items if the item has been updated. This is all really to get round requiring a context to update some stuff in the cache...this way I can do it 'offline'
using System;
using System.Timers;>
namespace CacheTimerTest
{
///
/// Summary description for TimerClass.
///
public class TimerClass
{
public TimerClass()
{
Timer timer = new Timer();
timer.Enabled=true;
timer.Interval=5000;
timer.Start();
timer.Elapsed +=new ElapsedEventHandler(timer_Elapsed);
}
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
if(!Global.qu.Contains("update1"))
Global.qu.Enqueue("update1");
}
}
}
So here's my question, can anyone think of a reason why this won't work reliably, as I say, I have a nagging feeling it won't but for the life of me I can't think why...
© 2025 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.