-
October 31st, 2006, 09:11 AM
#1
increamenting a for loop using seconds
hi
how can i increment the for loop with a second seed
for example
Code:
for( ; timer<10 seconds ; timer+=2 seconds )
{
}
i need to check for something but after s2 seconds between each check
i hope you understood me
-
October 31st, 2006, 09:49 AM
#2
Re: increamenting a for loop using seconds
Try to use a Timer. I prefer System.Timers.Timer.
Code:
Timer t = new Timer(2000);
t.Elapsed += new EventHandler(timer_Elapsed)
t.Start()
(...)
private void timer_Elapsed(object sender, EventArgs e)
{
//do whatever you want
}
-
October 31st, 2006, 02:13 PM
#3
Re: increamenting a for loop using seconds
thanx
i haven't test it yet(i'm not at home)
but i have 2 for loops that will be inside each other , so i don't know if the above code will work will
Code:
for ( step using seconds)
{
if(...){}
else
{
for(step using seconds)
if(..){}
else
{
....
}
}
}
-
November 1st, 2006, 08:02 AM
#4
Re: increamenting a for loop using seconds
Now that's a bunch of spagetti code.
Probably you can redesign that method to look better (perhaps not...)
You can use timers in your case. It's just a matter of having states (maybe you need a state machine?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|