Execute a Method at a Specific Time - CSharp Reflection

CSharp examples for Reflection:Method

Description

Execute a Method at a Specific Time

Demo Code


using System;//from  ww  w .ja  v a  2s.c om
using System.Threading;
using System.Globalization;

    class MainClass
    {
        public static void Main(string[] args)
        {
            TimeSpan waitTime = new TimeSpan(0, 0, 30);
            new Timer(delegate(object s)
            {
                Console.WriteLine("Timer fired at {0}",
                DateTime.Now.ToString("HH:mm:ss.ffff"));
            }
                      , null, waitTime, new TimeSpan(-1));
        }
    }

Related Tutorials