user1233208
user1233208

Reputation: 21

How can i run a function after the program being on 12hrs in a row?

How can i run a function on my program after the program was on for 12 hrs straight?

Upvotes: 2

Views: 67

Answers (1)

Tyson
Tyson

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

Related Questions