Re: multi-thread problem
I'm still having problems with this simple worker thread program. And I'm
still not sure how to write the cast for controller function. Could you
correctly write any incorrect statements. And also, I had another question.
I have found that there must be some procedure to correctly place the
message receiving function into the program. Is it placed with the wizard or
manually and static, public or private. And the message maps seem to be
causing some unusual problem. Here is what I've added:
// Generated message map functions
//{{AFX_MSG(CThreadTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnStart();
afx_msg LRESULT OnThreadFinished(UINT wParam, LONG lParam);
//}}AFX_MSG
ON_MESSAGE(UWM_THREAD_FINISHED, OnThreadFinished);
DECLARE_MESSAGE_MAP()
private:
static UINT Thread1(LPVOID lParam);
Are there any steps involved in adding these statements. I am getting
these errors:
error C2059: syntax error : '{'
error C2334: unexpected token(s) preceding '{'; skipping apparent function
body
------------------------------------------
I am getting this error message for code:
error C2660: 'Thread1' : function does not take 0 parameters
UINT CThreadTestDlg::Thread1(LPVOID lParam)
{
CThreadTestDlg* pDlg = (CThreadTestDlg *)lParam;
pDlg->Thread1();
long Num = 123456789;
pDlg->PostMessage(UWM_THREAD_FINISHED, (WPARAM)0, (LPARAM)Num);
return 0;
}
LRESULT OnThreadFinished(UINT wParam, LONG lParam)
{
return 0;
}
void CThreadTestDlg::OnStart()
{
AfxBeginThread(Thread1, this);
}
-----------------------------------------