I created a program that runs every day at 5:00 p.m. but when I debug the program the console always stays open I want to debug once is close my pc and demin when I open my pc without running the program another time the application runs at 5:00 pm automatically
var DailyTime = "5:00:00";
var timeParts = DailyTime.Split(new char[1] { ':' });
while (true)
{
var dateNow = DateTime.Now;
var date = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day,
int.Parse(timeParts[0]), int.Parse(timeParts[1]), int.Parse(timeParts[2]));
TimeSpan ts;
if (date > dateNow)
ts = date - dateNow;
else
{
date = date.AddDays(1);
ts = date - dateNow;
}
Task.Delay(ts).Wait();
Copie();
FichierTrace.Close();
Console.Read();