Thread: access violation
Posted on 2005-05-04
I have a threading problem. First, an overview of what I am trying to achieve.
I have a view class with an associated document. The document has a member variable that is an instance of a composite class, and is accesible from the view via
What I want to do is call a visitor on this variable from within my thread.
Here is what I am doing:
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
CWinThread* pThread = AfxBeginThread(ThreadFunc, (LPVOID)pMainFrame->m_hWnd);
UINT CMyViewView::ThreadFunc(LPVOID pParam)
CMainFrame* pMainFrame = (CMainFrame*)CWnd::FromHandle((HWND)pParam);
CMyViewView* pView = (CMyViewView*)pMainFrame->GetActiveView();
But this keeps breaking in GetActiveView()
CObject::IsKindOf(const CRuntimeClass * pClass=0x00475454)
CMyView::ThreadFunc(void * pParam=0x000f0a6a)
line causing trouble in IsKindOf():
CRuntimeClass* pClassThis = GetRuntimeClass();
result: Access violation reading location 0x0000111c.
How can I achieve what I am after, and is it a good idea ?