So i'm making an animation in .net using timers. and the execution of those timers is linked with a for loop. To make it more clear, imagine that for each loop iterration a timer is running for 5 sec. Now my problem is that the loop is not waiting for timer (animation) to finish, and it jumps to the next itrration ( i+1 ). Now how can i make a loop wait for timers to be in enabled = false ( this means animation is finished ) and then proces the next iterration. Here is the example of the loop. For i As Integer = 0 To 7 If panele(i).Tag > panele(i + 1).Tag Then swap(panele(i + 1), panele(i)) End If Next Code (markup): and i need the for loop to wait for the function swap to be finished before it continues on the next. and swap() lasts about 2 sec.
Just to clarify, are you using loops as timers or are you using functions to record time which are then used in loops? Unless you're using multi-threading, your swap function does finish and return before control is returned back to the loop.
Well since i only needed the swap function results with delay of 5 sec, i have let the loop store each result in listbox, then i just added an extra timer and read one by one result from listbox every 5 sec with a timer.
use delay(sec) function just before the NEXT with the number of seconds as in your animation... hope this helps
I don't know about the delay function but if you mean system.threading.sleep(sec), then that would be a bad solution cuz i have a running animation in the background and that would stop it too ( freeze the program ), unless if i use multithreading but then it's just complicated. I think the solution that i made with the timers is ok. Thanks for the help