C#定时器

 //1000=1秒
                int timeclock = 1000 * 60*5;
                System.Timers.Timer t = new System.Timers.Timer(timeclock);//实例化Timer类,设置间隔时间为五分钟;
                t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
                t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
                t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;  
    /// <summary>
        /// 定时开关
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void theout(object source, System.Timers.ElapsedEventArgs e)
        {
           //to do
            MessageBox.Show("OK!");
        }
原文地址:https://www.cnblogs.com/akonlei/p/5622418.html