I'm having a hard time using my custom events (actually it's only one atm) from threads. More specifically, the events are not received by the controlling class which starts the thread and is responsible for the program "to work". Latter class lies within a GUI.
I followed the "custom events" page's instruction in the wiki and also had some help on IRC (thanks, folks, and special thanks to DavidGH!) to flatten out some issues that might have been problematic too but in the end, my class still fails to respond to the event.
So I have this GUI class, which instantiates a "control" class which, in turn, starts and stops threads to do some work. What I want now is that given control class is informed when, e.g. an error occurs. My app fails there already The next step would be to pass that on to the GUI, but coming from the control then. The GUI has no knowledge about the control's workings and the threads.
All the samples I found regarding threading and events refer to wxFrame to get an event handler. Well, I want the control class to be independent of the GUI. While at the moment it's created in a wxFrame, I want it to be logically separated and e.g. be possible to use that class in a console application.
What I tried was calling AddPendingEvent(..) inside the thread's Entry() routine
- * using the GetEvtHandler() from wxGetApp()
* after inheriting the control class from wxEvtHandler and passing a control instance to the thread
* after inheriting the control class from wxEvtHandler, "pushing" that EventHandler and passing a control instance to the thread
Posting the whole project code here would certainly be considered spam so I zipped a ripped down minimal sample from my project and attach it to this post. Maybe someone likes to look at it. Any help is highly appreciated. In case of enlightenment I'm offering to improve the wiki page or create a new one of my own
PS: I'm using wxWidgets 2.8.9 with Visual Studio 2005 (for which a project solution is provided).