Hello,
i have problem about my code.
When i run this code hourly reporting method is working fine however
"
StartTimer(new TimeSpan(08, 39, 0), new TimeSpan(24, 0, 0), ProcessViewType.SingleRun);
StartTimer(new TimeSpan(08,40 ,0), new TimeSpan(24, 0, 0), ProcessViewType.ReportToBranch);
"
this part is not work.
I try debuging mode when the hourly timer is work sineglerun and the other timer is not work.How ever i delete the hourly event the others works fine.I think the hourly event Suppress the other events. How can i fix?
why? and how can i fix this problem?
timingToolStripMenuItem.Enabled = false;
StartTimer(new TimeSpan(15, 47, 0), new TimeSpan(24, 0, 0), ProcessViewType.ReportToBranch, true);
StartTimer(new TimeSpan(12, 44, 0), new TimeSpan(24, 0, 0), ProcessViewType.SingleRun,false);
StartTimer(new TimeSpan(12, 46, 0), new TimeSpan(24, 0, 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;
if (pc == ProcessViewType.ReportToBranch && Hourly == false)
{
callback = new System.Threading.TimerCallback(runReport);
}
else if (pc == ProcessViewType.SingleRun && Hourly == false)
{
callback = new System.Threading.TimerCallback(runSingleRun);
}
else if (pc == ProcessViewType.ReportToBranch && Hourly == true)
{
callback = new System.Threading.TimerCallback(runReport);
firstExecution = 1;
intervalPeriod=TimeSpan.FromMinutes(3).TotalMilliseconds;
}
_timer = new System.Threading.Timer(callback, null, Convert.ToInt32(firstExecution), Convert.ToInt32(intervalPeriod));
What I have tried:
changing timer line
first run the dayly timer the methods are called.