Using VC++ 6.0.
My experience thus far with multi-threading is minimal. My application basically takes BMP screen-captures, putting them in the users temp folder, and at incremental points and when asked, "saving" by renaming appropriately into the actual storage path (files are named with a standard convention, using incremental integer values to index the resulting files in a folder. This rename/move happens with the CFile::Rename() method. For my bitmap captures, this works quickly and is not an issue.
I've now added AVI capture support to my app, and am using the existing data management architecture to handle this. I'm finding though that the CFile::Rename() function, when called with a file that is potentially several hundred MB in size, pretty much slows my app to a standstill until it's complete. The UI still accepts mouse-clicks, rollovers etc. still work, but functionality stops. My messages are queued up and so eventually the app snaps back alive and quickly shoots through all actions the user may have tried during this freeze.
This to me says Thread (I think.. though it's only the one CFile::Rename() call that would have to be in a thread.. or is the issue disc access??). Basically everything's in place and working as expected, I'm only trying to fix the problem with the app hanging up until the files are renamed.
Each export is an instance of CMovie, which contains the following method (among many)
BOOL CMovie::SaveFilename(LPCTSTR path, LPCTSTR label, CString &name)
name = m_tmpName;
CString sOldName = GetFilename();
// we need to rename
CString sPath = path;
if (sPath.Right(1) != _T("\\") && sPath.Right(1) != _T(":"))
sPath += _T("\\");
CString format = label;
format += _T("_Movie%.3d.AVI");
long lCounter = 0;
while (++lCounter < 100000)
BOOL bCreate = FALSE;
if (!CFile::GetStatus(sPath+sNewName, stat))
// this is our new name...
m_MovieID = sNewName.Left(sNewName.GetLength() - 4);
m_tmpName = sNewName;
name = sNewName;
m_bTempFile = FALSE;
m_sPath = sPath;
} CATCH (CFileException, pFE)
// some problems... try another one
that while loop simply acts to find the next incremental index value to tack onto the filename it's saving. Generally this will only go 5-10 times depending on how many captures the user performed. My question is, what code do I need to add to put the CFile::Rename() call into a worker thread? OR - is a thread not the answer? I could do a bunch of re-work on the existing file management architecutre, to not use the users ~TEMP folder for intermediary saves of the AVI files, rather, placing them in the final storage location from the get-go, but that will require re-writing (or placeing elsewhere) some of the fundamental stuff that defines and sets up the directory structures in the first place. Doable, but if a thread is appropriate, I'd rather do that.