UINT ThreadProc ( LPVOID param )
-
Hello, i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code: void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel) { m_Thread_Sel_Start.SetEvent (); HWND hWnd = GetSafeHwnd(); m_strSelect = strSel; m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp // and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function } UINT ThreadProc ( LPVOID param ) { (CTestView*)param-> // casting to CTestView did not work? return 0; }
-
Hello, i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code: void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel) { m_Thread_Sel_Start.SetEvent (); HWND hWnd = GetSafeHwnd(); m_strSelect = strSel; m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp // and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function } UINT ThreadProc ( LPVOID param ) { (CTestView*)param-> // casting to CTestView did not work? return 0; }
I encourage you to read this [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I encourage you to read this [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hello, i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code: void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel) { m_Thread_Sel_Start.SetEvent (); HWND hWnd = GetSafeHwnd(); m_strSelect = strSel; m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp // and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function } UINT ThreadProc ( LPVOID param ) { (CTestView*)param-> // casting to CTestView did not work? return 0; }
Is there a question here that I'm failing to see? :confused:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Is there a question here that I'm failing to see? :confused:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
The question is when i pass (this) instead of (hwnd) to the ThreadProc function i get a crash. The question is above.
How about formatting your code correctly AND using the <pre> tag?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hello, i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code: void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel) { m_Thread_Sel_Start.SetEvent (); HWND hWnd = GetSafeHwnd(); m_strSelect = strSel; m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp // and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function } UINT ThreadProc ( LPVOID param ) { (CTestView*)param-> // casting to CTestView did not work? return 0; }
->
has higher precedence than a cast, you need parens around the cast so it's evaluated first:((CTestView*) param)->SomeMethod();
--Mike-- Dunder-Mifflin, this is Pam.
-
okoay but i have an application crash hier: #ifdef _DEBUG void CTestView::AssertValid() const { CView::AssertValid(); // application crash } #ifndef _WIN32_WCE void CTestView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif #endif
You shouldn't use
GUI
stuff in worker threads. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]