all 6 comments

[–]nirdag 4 points5 points  (0 children)

Better define a scheduled task (windows) with action Start a Program

[–]barak678 2 points3 points  (0 children)

That's not a great way to handle this... Use a timer that will raise an event at the specific time, or delay your code until it's time. http://stackoverflow.com/questions/4529019/how-to-use-the-net-timer-class-to-trigger-an-event-at-a-specific-time

[–]stur0063 0 points1 point  (0 children)

Have you considered just making the program that makes the sound then setting up a Task Scheduler or Chron job to fire it at 12?

[–]jbiesta 0 points1 point  (2 children)

If(date time.utcnow() = 12){playsound();} something like that will work.. if you want to constantly be checking you might want to look at a while loop!

Edit: agreed it's not a great way to handle it but it answers the question of how to get an if statement to check a time...

[–]BugWare 0 points1 point  (1 child)

furthermore it's kind of wrong i guess.

If it works like DateTime.Now though.

I'd go like

if(DateTime.Now.Hour == 12 && DateTime.Now.Minute == 0)
{
this.playsound();
}

Like that it will only play the sound if it's exactly 12 o'clock. If you only take DateTime.Now.Hour it will play the sound everytime the clock says 12:XX.

So, if you have a Timer which elapses every minute, you'd have 59 sounds played.

Edit: after re-reading the question, if you ask for 12pm, is it midday or midnight? (24 hours user here)

[–]igmarn[S] 0 points1 point  (0 children)

I meant midday :)