Hossein Zahed

Web Developer, Entrepreneur, Software Educator

Scheduled Tasks in asp.net

Essentially, you just create a System.Timers.Timer in the Application_Start event of your Global.asax, and bam – instant scheduled task! I don’t necessarily recommend this, but I guess if you had no other option it could work.

using System.Timers; 
 
public class Global : System.Web.HttpApplication
{
    protected void Application_Start(object sender, EventArgs e)
    {
        Timer timer = new Timer(1000);
        timer.Elapsed += (object s, ElapsedEventArgs args) =>
        {
            LetsDoSomethingAwesome();
        };
        timer.Start();
    }
}
Comments are closed