How do I make it when the time on my computer reaches 12:00 it will write on the "Hello World" console every day?
How do I make it when the time on my computer reaches 12:00 it will write on the "Hello World" console every day?
Create a Timer and then compare to the chosen time:
private static void Main(string[] args)
{
var t = new Timer(TimerCallback, null, 0, 1000);
Console.WriteLine("Pressione \'q\' para sair.");
while (Console.Read() != 'q') ;
}
private static void TimerCallback(object stateInfo)
{
if (DateTime.Now.Hour == 12 && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
Console.WriteLine("Hello World");
}