When you arrive at 12:00 every day write on the console [closed]

1

How do I make it when the time on my computer reaches 12:00 it will write on the "Hello World" console every day?

    
asked by anonymous 11.11.2017 / 15:24

1 answer

0

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");
}
    
12.11.2017 / 02:07