How to communicate with threads
Posted: Wed Aug 13, 2014 6:44 am
Hello Forum.
Maybe this has been discussed in the past, it didn't touch me as I found a good solution for me which worked perfect in the past. Unfortunately since 5.30 this method is not allowed any longer.
This is what I have done:
In every thread I used a Window-Element with a windows message queue and an event loop as nearly same as in the main thread. If I share data between those threads I just allocated a bunch of memory (a predefined structure) and send a user defined message (using PostMessage) to the window object of the thread holding a pointer to the buffer.
After the message was processed within the thread the memory gets freed up by the thread. Same in the other direction.
Since 5.30 it is no longer allowed to create windows within threads, even no gadgets and so on. This leads to a big problem for my projects. (Disabling the debugger helps at that point, but maybe will lead to problems later I want to avoid)
GUI which is created in threads now needs to be placed in the mainloop somehow, big code restructure is required, new elements and lists/ maps are in need to handle the amount of dynamic elements (windows, Gadgets) within the mainloop increasing the overhead in the mainloop.
ATM I cant see a good solution how to handle the communication to the threads and from the threads to the main thread.
Anyone have hints in this direction?
Maybe this has been discussed in the past, it didn't touch me as I found a good solution for me which worked perfect in the past. Unfortunately since 5.30 this method is not allowed any longer.
This is what I have done:
In every thread I used a Window-Element with a windows message queue and an event loop as nearly same as in the main thread. If I share data between those threads I just allocated a bunch of memory (a predefined structure) and send a user defined message (using PostMessage) to the window object of the thread holding a pointer to the buffer.
After the message was processed within the thread the memory gets freed up by the thread. Same in the other direction.
Since 5.30 it is no longer allowed to create windows within threads, even no gadgets and so on. This leads to a big problem for my projects. (Disabling the debugger helps at that point, but maybe will lead to problems later I want to avoid)
GUI which is created in threads now needs to be placed in the mainloop somehow, big code restructure is required, new elements and lists/ maps are in need to handle the amount of dynamic elements (windows, Gadgets) within the mainloop increasing the overhead in the mainloop.
ATM I cant see a good solution how to handle the communication to the threads and from the threads to the main thread.
Anyone have hints in this direction?