View Single Post
  #1 (permalink)  
Old 05-01-2008, 02:18 PM
gaylo565's Avatar   
gaylo565 gaylo565 is offline
Programmer
 
Join Date: May 2007
Location: flagstaff, az
Posts: 184
Last Blog:
String Manipulation wi...
Credits: 122
Rep Power: 9
gaylo565 is a jewel in the roughgaylo565 is a jewel in the roughgaylo565 is a jewel in the rough
Default using timer to elapse time before method?

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
Reply With Quote

Sponsored Links