I am working on an MFC based SDI (Explorer type) application which searches for 2 headers (BMP & JPG) in the logical drive selected by the user.
The searching headers job i am doing in a UI Thread.
As soon as any header is found i add it to a Linked list maintained by me and then i send messages to the mainframe & leftview class to update the interface..
In the mainframe class in the message handler function i update the progress bar in the statusbar pane 0 & headers found count in the statusbar pane 1.
In the leftview message handler function i create a folder by the name of the header found (ex: BMP) & add it to the tree.
Now after half of the logical drive processed 2 folder exists in the left view - BMP & JPG.
So far so good.....................
Now when the user clicks on any folder(for ex: BMP) in the leftview, i will show the thumbnails of the various bmp's found so far by the searching process & stored in the linked list.
I have used a worker thread to show the thumbnails.
Now there are two problems related to the above discussion:
1-----> When the thumbnails are being shown by the worker thread, the header searching UI threads hangs untill all thumnails are displayed. Please have a look at the code for the worker thread:
UINT LoadingThumbnails_WorkerThread(LPVOID pParam)
CSPhApp *pApp = ( CSPhApp* )AfxGetApp();
HWND hHandle = (HWND)pParam;
if(pApp->pTemp->dwParentId == pApp->dwCurrentlySelected_Dirs_FileId)
BOOL ret_Value = PostMessage(hHandle, WM_THUMBNAILS, 0, 0);
pApp->pTemp = pApp->pTemp->next;
}//end of while..
//When control comes here, loading of thumbnails is done.
pApp->LoadingThumbNails = FALSE;
Y is my UI thread hanging.
Waiting for suggestions