For example, I want to call a function in specific time intervals (hourly or daily tasks.)
I m already using Timer. But it is working as long as my local server is working. For Example:
public static void StartYahooWeatherManager()
{
Timer t = new Timer(1000 * 60 * 60 * 6 /* 6 hours */);
t.Elapsed += new ElapsedEventHandler(WriteYahoWeatherRssItemToDb);
t.Start();
}
private static void WriteYahoWeatherRssItemToDb(object o, ElapsedEventArgs e)
{
YahooWeatherManager.InsertYahooWeatherRssItem(YahooWeatherManager.GetYahooWeatherRssItem());
}
I write weather info to db, in 6 hour intervals. Project is already in Host. Timer event is working as long as my computer local server is running.
Question:
What is the wrong about my code? (Or logical wrong to using timer in WebProject?) Why timer is only working while local server working?
What is the best way to manage time interval tasks? (not need asp.net)
I hope, I can explain the problem. Thanks.