Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. _beginthread PROBLEM

_beginthread PROBLEM

Scheduled Pinned Locked Moved C / C++ / MFC
helpregex
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Caoimh
    wrote on last edited by
    #1

    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

    P B 2 Replies Last reply
    0
    • C Caoimh

      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

      B Offline
      B Offline
      Balkrishna Talele
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • C Caoimh

        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

        P Offline
        P Offline
        Prakash Nadar
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups