[ACCEPTED]-How to access the system clock in C#-c#

Accepted answer
Score: 18
DateTime time = DateTime.Now;

will get you the current time.

So if you 8 want to sleep until a specific time you can use 7 the TimeSpan to calculate the number of milliseconds 6 until then. You still will need to use thread.sleep or 5 better still System.Threading.Timer (or System.Timers.Timer) to pause the process.

If, however, you 4 want to start a process at a specific time, you'd 3 be better off creating a separate application 2 and creating a scheduled task to control 1 it. This is accessed via the Control Panel.

Score: 10

Your best bet for delay purposes instead 3 of sleep is to use a Timer. You set it for a 2 how often you want it to "tick" and 1 you get events when that happens.

Score: 4

Are you looking for DateTime struct and the DateTime.Now property?

DateTime.Now;

0

More Related questions