I am writing a course launch of programs on a schedule in C #, type of Windows Forms project. The instructor said to realize through a waitable timer. Here is my code:
private void Form1_Load(object sender, EventArgs e) { string date, time, datenow = DateTime.Now.ToShortDateString(), timenow = DateTime.Now.ToShortTimeString(), way; // MessageBox.Show(DateTime.Now.ToShortTimeString()); // MessageBox.Show(timenow); Process p = new Process(); using (StreamReader fs = new StreamReader(@"C:\Users\Master\Documents\Visual Studio 2013\Projects\Cursovaya OS 1\Cursovaya OS 1\bin\Debug\datetime")) { while (!fs.EndOfStream) { // Читаем строку из файла во временную переменную. date = fs.ReadLine(); //time = fs.ReadLine(); way = fs.ReadLine(); p.StartInfo.FileName = way; DateTime utc; utc=Convert.ToDateTime(date); // MessageBox.Show(utc.ToString()); long duetime = utc.ToFileTime(); handle = CreateWaitableTimer(IntPtr.Zero, true, "WaitableTimer"); SetWaitableTimer(handle, ref duetime, 0, IntPtr.Zero, IntPtr.Zero, true); uint INFINITE = 0xFFFFFFFF; int ret = WaitForSingleObject(handle, INFINITE); p.Start(); } But the process does not start. The format of the file is the date and time, as well as the path to the file:
08.03.2017 9:20 D:\Des1.txt Help please understand the problem.
await Task.Delay()? - VladD