I have to download a text file from my web server then call a read function that uses ifstream. Both work separately with no problems but when I try to get them to work together it fails miserably. The read function can't do its job unless the file has been downloaded, so I put URLDownloadToFile() first in the execution. Once the file is downloaded the next thing is read opens and reads the file. What I'm trying to do is have this in a continuous loop. I tried the nested for loop method..

Code:
for(int i = 0; i < 100; i++){
 read()
 for(int j = 0; j < 50; j++){
  URLDownloadToFile() }
}
But when I add it to the bottom of my code right before the return 0, it compiles fine, but it never executes in run time. Maybe because I have 8 threads starting above the code but I don't see how that could affect it. Any suggestions? If I left something out let me know, Thanx.