C# thread blocks C++ program -


i created c# lib use in c++ program (don't ask me why, there regulations).

the lib works expected, c++ program can call methods , should do.

one of methods (in lib) creates new thread , thread blocks whole application , c++ program won't continue.

c# lib:

public void startcommunication()         {             if(!connected)             {                 console.writeline("not connected!");                 return;             }             plattform = new robinm2(connection);             plattform.sendinitcommand();              communication = new thread(new threadstart(sendnextcommand));             communication.start();         } 

c++:

coinitialize(null);  robstepremotelibrarycsharp::irobstepptr interf(__uuidof(robstepremotelibrarycsharp::robstep));  std::wcout << interf->test() << std::endl;  interf->connecttoplattform("192.168.0.1"); interf->startcommunication(); 

the method "startcommunication" called, never returns main program.

my first (and ugly) idea call method in thread:

coinitialize(null);  robstepremotelibrarycsharp::irobstepptr interf(__uuidof(robstepremotelibrarycsharp::robstep));  std::wcout << interf->test() << std::endl; interf->connecttoplattform("192.168.0.1"); _beginthread(test,0, (void*)&interf);  void test(void* param) {     robstepremotelibrarycsharp::irobstepptr newparam = *(robstepremotelibrarycsharp::irobstepptr*) param;     newparam->startcommunication(); } 

my platform doesn't support c++11 therefore can't use "include thread".

this works, ugly hell. have suggestions?

ps: please change title , tags, not sure how describe problem.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -