I am trying to set a function to run at a specific time in a day in c#. This code seems to work but I am not so confident about it. Is there any better way around this?
this is my code
String thetimeis = DateTime.Now.ToString("HH:mm:ss");
DateTime alarmtimeStart = Convert.ToDateTime("12:00:00");
DateTime alarmtimeStop = Convert.ToDateTime("12:02:00");
if (Convert.ToDateTime(thetimeis) > alarmtimeStart && Convert.ToDateTime(thetimeis) < alarmtimeStop)
{
MessageBox.Show(thetimeis);
}