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. Thread Programming & Matlab

Thread Programming & Matlab

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
4 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.
  • S Offline
    S Offline
    samr67
    wrote on last edited by
    #1

    Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }

    A K 2 Replies Last reply
    0
    • S samr67

      Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }

      A Offline
      A Offline
      Abbas_Riazi
      wrote on last edited by
      #2

      Try CreateThread and _beginThread! A. Riazi

      S 1 Reply Last reply
      0
      • A Abbas_Riazi

        Try CreateThread and _beginThread! A. Riazi

        S Offline
        S Offline
        samr67
        wrote on last edited by
        #3

        Hi A. Riazi, Many thanks for your reponse. I have tried CreateThread with no success. I have also eliminated MATLAB now (ie the function that initiates the thread is main() not mexFunction) and the problem is still there. Any further suggestions? Regards, Sam

        1 Reply Last reply
        0
        • S samr67

          Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }

          K Offline
          K Offline
          kochhar
          wrote on last edited by
          #4

          Try replacing: AfxBeginThread(THREADD1,NULL); with: AfxBeginThread(THREADD1,NULL,0,0,0,NULL);

          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