Sleep Function Needed
I have the following function. When the user hits F3, it invokes this function. At the bottom of the function, there is a while loop based off of the number of files found in a directory. It will process these files (converts them from text to binary and moves them - which are in other classes).
What I need is a sleep function, to stop and wait 30 seconds, then rerun the while loop (actually start from where
bWorking = mapsFinder.FindFile( filePattern ); is.
How can I do this? Thanks!
void CInkView::OnF3loadtextmap()
{
//
CString filePath;
CString txtFileDir;
CString fileExt;
CString filePattern;
CString outFilePath;
CString outSaveDir;
GetDocument()->pLot = new CLot( GetDocument() ); // Create the new Lot object with a pointer to the doc
txtFileDir = GetDocument()->pInit->CamtekOutputDir();
fileExt = "\\*.txt";
filePattern = txtFileDir + fileExt;
outFilePath = GetDocument()->pInit->CamtekToMapDir();
outSaveDir = GetDocument()->pInit->CamtekSaveDir();
CFileFind mapsFinder;
BOOL bWorking;
bWorking = mapsFinder.FindFile( filePattern ); // Check the primary map directory first.
while (bWorking) // Continue while there are more files.
{
bWorking = mapsFinder.FindNextFile();
filePath = mapsFinder.GetFilePath();
GetDocument()->pLot->CamtekToMap(filePath, outFilePath, outSaveDir);
}
}
[1571 byte] By [
sanclan] at [2007-11-19 18:28:35]

# 5 Re: Sleep Function Needed
The application will be continuous. It looks at a directory, pulls text files from it, converts them to another format, moves them, waits 30 seconds, does it again. It'll do this 24/7.
Thanks,
Jeff
# 7 Re: Sleep Function Needed
The application will be continuous. It looks at a directory, pulls text files from it, converts them to another format, moves them, waits 30 seconds, does it again. It'll do this 24/7.
Thanks,
Jeff
Ok then, now that you explained it:
This code should be in a worker thread, cause you defiantly dont want to block the main thread for such long time.
One more thing, why you are not using the ::ReadDirectoryChangesW(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/readdirectorychangesw.asp) api ?
Just an idea ;)
/EDIT: Ah MrViggy was faster :D :thumb:
Cheers
# 8 Re: Sleep Function Needed
Thanks for all of the information. I'll look into both of those. As you can probably see, I am fairly new to Visual C++, I came over from Visual Basic.
I have created the converters, just need to make them robust and harvest these files continuously. I was trying to keep it very simple.
Thanks again!
JEFF