CFrameWnd::AssertValid() fails in debug mode
I have Doc/View application.
Upon one user command I create thread passing some user-defined data to it.
This is the thread procedure:
And here's DlgLocalCopy::LocalFolderCopy() funcion, which is called from the thread above:
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);
But calling CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument()
void DlgLocalCopy::LocalFolderCopy(LPCTSTR pth, BYTE &type, THREAD_COPY_PARAM *p_param)
___CMainFrame* mf = (CMainFrame*) AfxGetApp()->GetMainWnd();
___CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument();
fails in CWnd::AssertValid()
on this line:
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
ASSERT((CWnd*)p == this); // must be us
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.