In my main method I'm constantly checking if given time is equal to current time. But my code seems to fail. This is a windows forms application, not a console application. Not trying to convert string to time span, need some way of checking if two times are equal.
static void Main()
{
TimeSpan start = TimeSpan.Parse("10:09:00");
while (true)
{
TimeSpan now = DateTime.Now.TimeOfDay;
if (now == start)
{
Debug.WriteLine("Fount at " + now + " " + start);
Environment.Exit(1);
}
Debug.WriteLine("Running Loop at " + now + " "+start);
}
}
I tried altering the first line as,
TimeSpan start = TimeSpan.Parse("10:09:00:0000000");
That doesn't seem to work either, Can anybody suggest me a better way?