When you get to 12:00 every day write on the console

Asked

Viewed 56 times

2

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

  • I can’t understand what you want to ask.

  • Ready I edited..

1 answer

1


Creates a Timer and then compares with 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");
}
  • I wish it was every day

  • 2

    if you leave the running application will run every day at 12:00 pm...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.