Doing something at a specific time is not much different from doing it periodically.
Let's say you want to do something at some point in the future. We'll call that targetDate
.
DateTime targetDate = GetActionTime(); // whatever
// compute the difference between targetDate and now.
// we use UTC so that automatic time changes (like daylight savings) don't affect it
TimeSpan delayTime = targetDate.ToUniversalTime() - DateTime.UtcNow;
// Now create a timer that waits that long ...
Timer t = new Timer(TimerProc, null, delayTime, TimeSpan.FromMilliseconds(-1));
That timer will trigger the callback once. If you want that to repeat at the same time every day, you can pass the target date (or perhaps a reference to the record that describes the whole event) to the timer proc, and have the timer proc update the target date and then call Timer.Change
to change the timer's due time. Be sure to set the period to -1 milliseconds in order to prevent it from becoming a periodic timer.