Reputation: 21
How can i run a function on my program after the program was on for 12 hrs straight?
Upvotes: 2
Views: 67
Reputation: 14734
Use a timer:
var timespan = new TimeSpan(12, 0, 0);
var timer = new System.Timers.Timer(timespan.TotalMilliseconds);
timer.Elapsed += (o, e) =>
{
// runs code here after 12 hours.
};
timer.Start();
Upvotes: 2