How do I ensure that my program's output is complete?
Posted on 2011-03-10
I created a program that iterates through the records of 5000 students using a For...Next loop.
For each student the program creates a summary of all of the classes he/she has taken, their grades in each class, their quarterly progress reports from all of their teachers, and then prints them out into a text file, C:\Output.txt.
Now, some students have much longer summaries than others, especially if teachers write long progress reports and leave lots of comments.
I am finding that the C:\Output.txt is often incomplete....how do I ENSURE that the program WAITS for a student's profile to be OUTPUTTED to the text file BEFORE moving on to the other functions that reports the students' grades?
I do NOT want to set a Sleep() that is a constant number because then some students may have profiles that are super short, and the sleep function ends up taking more time than is needed. ...I want the function to take as long as it NEEDS to finish its analysis and as long as it NEEDS To output that analysis to the text file. Sleep, pause, delay do not seem to solve the problem.
I need some kind of "wait...until" function. As in "wait..until" the output function finishes outputting to text...or "wait...until" the calculation function is done calculating a student's score. How do I do this?