_beginthread PROBLEM
-
Require some help in relation to the problem illustrated below struct THREAD_CONTROL { HNADLE hDevice; HANDlE hEvent; }; HANDLE inThreadControl; inThreadControl.hDevice = hDeviceWrite; inThreadControl.hEvent = WriteEvent; _beginthread(ThreadEZUSBWrite,0, &inThreadControl); void ThreadEZUSBWrite(THREAD_CONTROL pThreadCtrl) { // TODO HERE } error C2664: '_beginthread' : cannot convert parameter 1 from 'void (struct THREAD_CONTROL)' to 'void (__cdecl *)(void *)' None of the functions with this name in scope match the target typ Suggested appreciated Kind Regards Kevin
-
Require some help in relation to the problem illustrated below struct THREAD_CONTROL { HNADLE hDevice; HANDlE hEvent; }; HANDLE inThreadControl; inThreadControl.hDevice = hDeviceWrite; inThreadControl.hEvent = WriteEvent; _beginthread(ThreadEZUSBWrite,0, &inThreadControl); void ThreadEZUSBWrite(THREAD_CONTROL pThreadCtrl) { // TODO HERE } error C2664: '_beginthread' : cannot convert parameter 1 from 'void (struct THREAD_CONTROL)' to 'void (__cdecl *)(void *)' None of the functions with this name in scope match the target typ Suggested appreciated Kind Regards Kevin
This is wrong way to pass multi paramater in thread, instead use #include "process.h" beginthread(MyFun,0,reinterpret_caste(this)); . . MyFunc(LPVOID pThis); DWORD CMyclass::MyFunc(LPVOID pThis) { CMyClass *pThisObj = static_cast(pThis); pThis->UseurClassFunctions..... . . . } regards Balkrishna Talele
-
Require some help in relation to the problem illustrated below struct THREAD_CONTROL { HNADLE hDevice; HANDlE hEvent; }; HANDLE inThreadControl; inThreadControl.hDevice = hDeviceWrite; inThreadControl.hEvent = WriteEvent; _beginthread(ThreadEZUSBWrite,0, &inThreadControl); void ThreadEZUSBWrite(THREAD_CONTROL pThreadCtrl) { // TODO HERE } error C2664: '_beginthread' : cannot convert parameter 1 from 'void (struct THREAD_CONTROL)' to 'void (__cdecl *)(void *)' None of the functions with this name in scope match the target typ Suggested appreciated Kind Regards Kevin
Did you declare the prototype of the thread function before it is called? and also the input parameter of the thread function is and should be void* not THREAD_CONTROL so in a nutshell //thread proc
void ThreadEZUSBWrite(void* pThreadCtrl)
{
THREAD_CONTROL *pControl;
pControl = (THREAD_CONTROL*) pThreadCtrl;
// TODO HERE}
//and to start the thread.
...
_beginthread(ThreadEZUSBWrite,0, (void*)&inThreadControl);
...
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time. 2.Why do people ask for time from people who are not wearing a wrist watch. Prakash, India.