I have Doc/View application.
Upon one user command I create thread passing some user-defined data to it.
This is the thread procedure:
PHP Code:
UINT ThreadLocalCopy(LPVOID pParam)
{
___THREAD_COPY_PARAM* p_info = (THREAD_COPY_PARAM*)pParam;
___BYTE type = 0;
___DlgLocalCopy::LocalFolderCopy("", type, p_info);
___// finish operation
___::SendMessage(p_info->h_wnd, WM_THREADFINISHED, 0, 0);
___return 0;
}
And here's DlgLocalCopy::LocalFolderCopy() funcion, which is called from the thread above:
PHP Code:
void DlgLocalCopy::LocalFolderCopy(LPCTSTR pth, BYTE &type, THREAD_COPY_PARAM *p_param)
{
___DlgOverwrite1 dov;
___DlgGetText dgt;
___DlgExpandSelection ds;
___CFileFind fff;
___CMainFrame* mf = (CMainFrame*) AfxGetApp()->GetMainWnd();
___CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument();
___.
___.
___.
}
But calling CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument()
fails in CWnd::AssertValid()
on this line:
PHP Code:
ASSERT((CWnd*)p == this); // must be us
Why? I think that the stuff I am doing here is thread-safe, isn't it? I am not passing any CWnd objects to thread, I just call
PHP Code:
AfxGetApp()->GetMainWnd()->GetActiveDocument()
inside the thread and it is not forbidden, is it?
Or if it is, how to achieve it another (safe) way?
Any help would be gratefully appreciated.
Standa.