Reputation: 145
My android app uses a timer in a certain place. I get an exception when the time exceeds an hour (3600000), it says the period is too large.
myTime = "3600000";
TempTimer = new System.Threading.Timer ((o) => {
ContentCheck(); // function call/ Void call <----------
}, null, 0, Int64.Parse(myTime) );
I've tried int.parse()
already, so tried int64
(Hence it being in code..)
Is there a timer that can do an hour AND longer? Or perhaps and alternative method to get the same results as a timer?
Upvotes: 1
Views: 156
Reputation: 2434
Timer timer = new Timer();
timer.Interval = 3600000;
timer.AutoReset = false;
timer.Start ();
timer.Elapsed+= Timer_Elapsed;
void Timer_Elapsed (object sender, ElapsedEventArgs e)
{
Console.WriteLine("Timer has gone off");
}
Here the interval property of timer instance is of type Double. So that can store really large values. So this should work for you.
Upvotes: 2