B
Ben Fidge
Using Visual Studio 2005, how would I go about creating an application-wide
timer hosted in global.asax? There's certain processes I want to run every
couple of minutes and have had success using tiemrs this way with VS.NET
2003.
However, global.asax seems to have lost it's visual designer in the new VS
2005, so I tried manually creating a timer class in the Global()
constructor, but the Elapsed event doesn't fire. My code is as follows:
public class Global : HttpApplication
{
private System.Timers.Timer tmrMain;
public Global()
{
InitializeComponent();
tmrMain = new System.Timers.Timer(60000);
tmrMain.Enabled = true;
tmrMain.Elapsed += new
System.Timers.ElapsedEventHandler(this.tmrMain_Elapsed);
((System.ComponentModel.ISupportInitialize) (tmrMain)).EndInit();
}
private void tmrMain_Elapsed(object sender, System.Timers.ElapsedEventArgs
e) {
// Do functionality
}
}
Any ideas?
Ben
timer hosted in global.asax? There's certain processes I want to run every
couple of minutes and have had success using tiemrs this way with VS.NET
2003.
However, global.asax seems to have lost it's visual designer in the new VS
2005, so I tried manually creating a timer class in the Global()
constructor, but the Elapsed event doesn't fire. My code is as follows:
public class Global : HttpApplication
{
private System.Timers.Timer tmrMain;
public Global()
{
InitializeComponent();
tmrMain = new System.Timers.Timer(60000);
tmrMain.Enabled = true;
tmrMain.Elapsed += new
System.Timers.ElapsedEventHandler(this.tmrMain_Elapsed);
((System.ComponentModel.ISupportInitialize) (tmrMain)).EndInit();
}
private void tmrMain_Elapsed(object sender, System.Timers.ElapsedEventArgs
e) {
// Do functionality
}
}
Any ideas?
Ben