MFC + Threading = C2665
-
I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?
// Prototypes:
void ExecuteThread(LPVOID lParam)// Button to launch the worker:
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker Thread:
void ExecuteThread(LPVOID lParam)
{//cpu->Execute(); MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK ); return;
}
-
I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?
// Prototypes:
void ExecuteThread(LPVOID lParam)// Button to launch the worker:
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker Thread:
void ExecuteThread(LPVOID lParam)
{//cpu->Execute(); MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK ); return;
}
You haven't been reading your documentation!!! ;P Try this.
UINT __cdecl ExecuteThread( LPVOID pParam );
«_Superman_» I love work. It gives me something to do between weekends.
-
I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?
// Prototypes:
void ExecuteThread(LPVOID lParam)// Button to launch the worker:
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker Thread:
void ExecuteThread(LPVOID lParam)
{//cpu->Execute(); MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK ); return;
}
Killiconn wrote:
void ExecuteThread(LPVOID lParam)
Are you missing the ';' behind the function declaration. By the way what are the compilation errors that you get? The possible solutions for C2665 are * Supply a conversion operator. * Use explicit conversion. but can't really say if they help you in resolving your problem
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?
// Prototypes:
void ExecuteThread(LPVOID lParam)// Button to launch the worker:
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker Thread:
void ExecuteThread(LPVOID lParam)
{//cpu->Execute(); MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK ); return;
}
-
You haven't been reading your documentation!!! ;P Try this.
UINT __cdecl ExecuteThread( LPVOID pParam );
«_Superman_» I love work. It gives me something to do between weekends.
The reason I ended up trying void, along with any other things is that UNIT dosn't show up as a data type. Is there a header that needs to be included? Having trouble researching it because everything that comes back is about unit testing. From one page it looked like UNIT meant use, int, long, or short, but tried and non of those worked. Tried with and without the __cdecl as well. Never come across the UNIT before and wishing right now I never had. Code looks basically the same. Any ideas?
// Launcher
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker
UNIT __cdecl ExecuteThread(LPVOID lParam)
{
MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB_OK );
} -
The reason I ended up trying void, along with any other things is that UNIT dosn't show up as a data type. Is there a header that needs to be included? Having trouble researching it because everything that comes back is about unit testing. From one page it looked like UNIT meant use, int, long, or short, but tried and non of those worked. Tried with and without the __cdecl as well. Never come across the UNIT before and wishing right now I never had. Code looks basically the same. Any ideas?
// Launcher
void CVisualEmulatorDlg::OnBnClickedRun()
{
HWND hWnd = GetSafeHwnd();CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL); //cpu->Execute();
}
// Worker
UNIT __cdecl ExecuteThread(LPVOID lParam)
{
MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB_OK );
}typo typo typo typo Its UINT not UNIT.
«_Superman_» I love work. It gives me something to do between weekends.
-
typo typo typo typo Its UINT not UNIT.
«_Superman_» I love work. It gives me something to do between weekends.