I am currently working on a project with a timer in it. I am having trouble getting this part of my project to work. I need it to pause for a few seconds before it runs the next method. I can't just place the next method in the tick handler because it needs several variables to be passed to it. I could make the next method into its own class but I need it to modify lots of controls on the current form and this would be the long way around. Is there a way I can make a tick handler return a booleen so that once the time elapses I can run my next method? Any other simple solutions?
Code:
private static void keepTime()
{
System.Timers.Timer timer2 = new System.Timers.Timer();
timer2.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Tick);
timer2.Start();
}
private static void timer2_Tick(object obj, ElapsedEventArgs e)
{
//elapse 4 sec
int intTime = 0;
while(intTime < 4)
{
intTime++;
}
if(intTime >= 4)
{
timer2.Stop();
}
}
this is pretty much the timer im using as of now...doesn't serve desired purpose so any sort of timer is fine...Using VS 2003