Hello
private void timingToolStripMenuItem_Click(object sender, EventArgs e)
{
StartTimer(new TimeSpan(10, 00 , 0), new TimeSpan(24,00 , 0), ProcessViewType.SingleRun, false);
StartTimerH(new TimeSpan(09, 30, 0), new TimeSpan(01, 00, 0), ProcessViewType.ReportToBranch, false);
}
protected void StartTimer(TimeSpan scheduledRunTime, TimeSpan timeBetweenEachRun,ProcessViewType pc,bool Hourly)
{
double current = DateTime.Now.TimeOfDay.TotalMilliseconds;
double scheduledTime = scheduledRunTime.TotalMilliseconds;
double intervalPeriod = timeBetweenEachRun.TotalMilliseconds;
double firstExecution = current > scheduledTime ? intervalPeriod + (intervalPeriod - current) : scheduledTime - current;
System.Threading.TimerCallback callback = null;
callback = new System.Threading.TimerCallback(runSingleRun);
_timer = new System.Threading.Timer(callback, null, Convert.ToInt32(firstExecution), Convert.ToInt32(intervalPeriod));
}
when i run this code on 12:00 pm i got error which is " An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: The number must be non-negative and less than or equal to Int32.MaxValue, or -1."
What I have tried:
When i change the time to 9:00 am this error does not show.