Peter Bromberg posted this Rob Howard sample a few days ago :
using System;
using System.Web;
using System.Threadin g;
using System.Data;
using System.Data.Sql Client;
using System.Configur ation;
namespace BlackbeltBLL {
public class BackgroundServi ce : IHttpModule {
static Timer timer;
int interval = 5000;
public String ModuleName {
get { return "BackgroundServ ice"; }
}
public void Init(HttpApplic ation application) {
// Wire-up application events
if (timer == null)
timer = new Timer(new TimerCallback(S cheduledWorkCal lback), application.Con text, interval, interval);
}
public void Dispose() {
timer = null;
}
private void ScheduledWorkCa llback (object sender) {
HttpContext context = (HttpContext) sender;
Poll(context);
}
void DoSomething (HttpContext context) {
}
#region DB Poll
void Poll (HttpContext context) {
SqlConnection connection = new SqlConnection(C onfigurationSet tings.AppSettin gs["Northwind"]);
SqlCommand command = new SqlCommand("SEL ECT * FROM changenotificat ion", connection);
SqlDataReader reader;
string key = ConfigurationSe ttings.AppSetti ngs["SqlDepende ncy"];
connection.Open ();
reader = command.Execute Reader();
while (reader.Read()) {
string tableKey = String.Format(k ey, reader["Table"]);
if (context.Cache[tableKey] != null) {
int changeKey = int.Parse( context.Cache[ String.Format(k ey, reader["Table"])].ToString() );
if (changeKey != int.Parse(reade r["ChangeID"].ToString() ))
context.Cache.R emove(tableKey) ;
}
}
connection.Clos e();
}
#endregion
}
}
---000---
Juan T. Llibre, asp.net MVP
aspnetfaq.com :
http://www.aspnetfaq.com/
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
=============== =============== =====
<ab**********@h otmail.com> wrote in message news:11******** **************@ t39g2000cwt.goo glegroups.com.. .
HI,
i am using visual web developer for .net 2.0.
does .NET 2.0 comes with a timer control, i was unable to find it in
the IDE, where is it ?
thanks,
Abhishek