Skip to content Skip to sidebar Skip to footer

How To Use Closed Handle In A Worker Thread

I'm using threads in Windows to connect a plug-in made in c++ to a python script. The thread is to be called many times in the duration of the session Question: If I pass the ArgLi

Solution 1:

So, i finally found the problem. Hope this helps anyone who has the same problem i did

I still don't fully understand how this works but i basically need to dynamically allocate memory on the heap using new in c++ (and malloc in c). More information about this here

In my case I will need to do something like this:

#define NUM_ARGUMENTS 4typedefstruct{
int argc;
char *argv[NUM_ARGUMENTS];
}SENDTOPY;

And then on the main thread:

SENDTOPY *cmd;

char *argv[4]={"PythonPlugIn2","bridge","test_callsign","MAH543"};
int i;

cmd= new SENDTOPY();
cmd->argc=4;
for( i = 0; i < NUM_ARGUMENTS; i++ )
{cmd->argv[i] = argv[i];}

handle=(HANDLE) _beginthread(py_embed,0,(void*)cmd);

I still need to understand this better, and also learn how to deallocate at the end with delete but I'm in the right way.

Note: I still need help on the Question1 related to this, so please have a look at it.

Post a Comment for "How To Use Closed Handle In A Worker Thread"