public void ResetTimer() { // Main functiion is used to start timer. double dblTimeToRun = 1.0; // Get the time to run from the app.config file. string sTimeToRun = ConfigurationManager.AppSettings["TimeToRun24Decimal"]; if (sTimeToRun != "") { dblTimeToRun = Convert.ToDouble(sTimeToRun); } // Create the .NET object used to run our process object. RunProcess oProcess = new RunProcess(); // Create the timer object used to run our process object at the specificied time. var t = new System.Threading.Timer(new System.Threading.TimerCallback(oProcess.ProcessData)); // Figure how much time until 1:00 AM DateTime now = DateTime.Now; DateTime oneAM = DateTime.Today.AddHours(dblTimeToRun); // If it's already past 4:00, wait until 4:00 tomorrow if (now > oneAM) { oneAM = oneAM.AddDays(1.0); } int msUntilOneAM = (int)((oneAM - now).TotalMilliseconds); // Set the timer to elapse only once, at 1:00. t.Change(msUntilOneAM, System.Threading.Timeout.Infinite); LogData("XXXX - The Name or Description of the Program - XXXX : set to run at : " + oneAM.ToString()); Console.WriteLine("XXXX - The Name or Description of the Program - XXXX : set to run at : " + oneAM.ToString()); Console.ReadLine(); }
private void OTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { RunProcess oProcess = new RunProcess(); oProcess.ProcessData(""); }
private static void RunForWatchFilePath(object source, FileSystemEventArgs e) { RunProcess oProcess = new RunProcess(); oProcess.ProcessData(e.FullPath); }