Schedule Global Task by using static System.Timers I'm using System.Timers to schedule tasks. I find this working, but I'm not quite sure if it's ok to do it this way. 

using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Timers;
using System.IO;
using System.Threading;

namespace WebApplication2
{
    public class Global : System.Web.HttpApplication
    {
        public static System.Timers.Timer timer1 = new System.Timers.Timer();

        protected void Application_Start(object sender, EventArgs e)
        {
            timer1.Interval = 100;
            timer1.Elapsed += timer1_Elapsed;
        }

        void timer1_Elapsed(object sender, ElapsedEventArgs e)
        {
            timer1.Stop();
            // Example: Execute Task after 6 hours
            Thread.Sleep(6 * 60 * 60 * 1000);
            // Do something. Example:
            File.AppendAllText("C:\\log.txt", DateTime.Now + "\r\n");
        }
    }
}


By using this method, I can start the task anywhere in the application by calling this:

WebApplication2.Global.timer1.Start();


What do you think?
There's no reason to expose timer1 as a public member, I would just have a static method DoFoo() that calls timer1.Start().

There are a few issues with the way you implement you thread passing.  With the short interval and the immediate stop it seems that you are trying to just pass the job to another thread.  This can fail in a variety of ways:


Multiple calls to DoFoo() in quick succession will result in just one invocation of timer1_Elapsed
Under heavy load or immediately after startup, it may take more than 100 ms to reach time1.Stop().  This way one call to DoFoo() can result in multiple invocations of timer1_Elapsed.
Sleeping in a thread is the last thing you want to do.  You are occupying this thread for 6 hours for no good reason.  Further, your application may not be running in 6 hours.


So how do you fix it?  If you really need to sleep for 6 hours and the task is important, you need to save the job to an external store (like a database) in case your process terminates.  If it's just about scheduling work on another thread, that's what the ThreadPool is for.  If you do need the delay but it's not critical work, you can create a Timer with the long delay.  Make a new one for each call, and make sure you store a reference so it doesn't get GC'ed before it fires.