I have 3 modules that are called each with a timer and a thread. I want the 2nd one to wait until the first thread is done running and the 3rd one to wait until the 2nd one is done running.
Should the thread be structured in such a way or should a while loop be used to keep the successive thread from starting such as the following between threads and timers
Main window sets a variable to IsThreadRunning = True
Start new process with timer and thread
When thread ends set IsTheradRunning = False (does this in the Action method of timer)
While IsThreadrunning
app.doevents
wend
Start next process with timer and thread
When thread ends set IsThreadRunning = False
All three threads can start, then the second and third ones immediately pause themselves. The first thread, as it completes, can resume the second thread, which, when it also completes, resumes the third thread.
It does seem like 1 should call 2, and 2 should call 3. A CriticalSection could be useful here too. Each would all lock on the same object. When called in order, the first would get the lock, while the second and third would be blocked. Once the first releases the lock, the second would immediately unlock. And same for the second and third.
It’s already in a bad way with DoEvents unless this is a console app. He should do as @Thom_McGrath said and have the process run 1 through 3 with each calling the next. Or, alternatively, sucblass thread and include an event for finished and call the next one there.