Date: 10.01.2017 10:43:24
Создайте такой класс:
using System; using System.Timers; using System.IO; public class Example { private static System.Timers.Timer aTimer; public static void Initialize() { // Create a timer with 10 minutes interval. aTimer = new System.Timers.Timer(10*60*1000); // Hook up the Elapsed event for the timer. aTimer.Elapsed += OnTimedEvent; aTimer.AutoReset = true; aTimer.Enabled = true; } public static void OnTimedEvent(Object source, ElapsedEventArgs e) { // Write system time to log file using (StreamWriter sw = new StreamWriter("log.txt",true)) { sw.WriteLine(DateTime.Now.ToString()); } } }
при запуске программы (или службы) вызовите метод Initialize
Автор: VadimTagil