[ACCEPTED]-How to access the system clock in C#-c#
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.
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.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.