I have been trying to pass a Map to a thread using CreateThread(@MyThread(),myMap()) but the map is always empty. The compiler does not complain so I am assuming it should work. Can anyone confirm that passing a Map to a thread is or is not possible?
You can pass a pointer to CreateThread(). It is far better to pass a pointer to your structured thread. Then act on the state you are in; PAUSE, RESUME, STOP, DO_SOMETHING_SPECIAL.
The maps and arrays can be updated in the called thread procedure.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
You have to show a code snippet.
My threads come and go, but do not house any data structures.
They act on data structures within the calling procedure.
Search mk-soft and infratec for their excellent thread examples.
This is my thread stucture.
I use threads all the time with structures and they work perfectly. The problem I am trying to solve is whether a map of structures can be passed to a thread. I have an app that monitors a serial port and passes a structure to the thread that captures the data etc. Now the app needs to monitor two serial ports so I need to pass two structures to the thread. So I thought I would use a map of structures but it does not work as expected since the map is empty.
I guess I can always create another structure with pointers to the two serial port structures.
That is close to what I am doing except that the thread must handle both ports. So there is only one thread accessing two ports. So I want myThread to work as shown below.
You can't be pass Map or any other object to a thread, you need to stick to a raw pointer for the thread function. May be the doc is not clear enough about this subject
I did not realize that passing a map was not a pointer but then again I do not know much about the internal structure of maps so thank-you for the clarification and perhaps a mention about MAPs might be helpful in the documentation.
It worked perfectly once I switched to passing a pointer to a structure.