I want to call a function on every after one hour. I wrote this function in Global.asax file on Aplication_Start event. Its work fine in Local Host but not working after publishing it on web server.
here is my code:
protected void Application_Start(object sender, EventArgs e)
{
Application["UsersOnline"] = 0;
System.Timers.Timer time = new System.Timers.Timer();
time.Start();
time.Interval = 600000; // 30 min //3.6e+6; // 1 hour
time.Elapsed += time_elapsed;
}
public void time_elapsed(object sender, ElapsedEventArgs e)
{
DateTime value = new DateTime(DateTime.UtcNow.AddHours(5).Year, DateTime.UtcNow.AddHours(5).Month, DateTime.UtcNow.AddHours(5).Day,0,0,0);
TimeSpan ts = DateTime.UtcNow.AddHours(5) - value;
if (ts.Minutes >= 0 && ts.Minutes < 60 && ts.Hours == 0) // Creating range from :00 to :59
{
FeesClass.ApplyLateFees();
}
}