Reputation: 41
In short I'm trying to implement a GUI to my networking app. Both of them have mainloop() so I'm trying to put them into separate threads and I'm using boost::thread for it.
//standard initialization of boost::thread
GuiThread.join();
NetworkThread.join();
However, above crashes for some reason unknown. I'm searching for any way to do the same thing so any suggestion will be appreciated.
Thanks in advance, Red.
EDIT:
I'm creating boost::thread GuiThread of the wxWidgets mainloop like so:
boost::thread GuiThread = boost::thread ( boost::bind( &myAppClass::MainLoop(), this));
and Networkthread same way.
then i rewrite wxApp OnRun() function like so:
int OnRun() {
GuiThread.join();
NetworkThread.join();
return 0;
}
when i run it ( in vs2010 ), it says: myApp.exe has triggered a breakpoint and if i press continue it stops showing the window, if i press break it shows me assembly.
Upvotes: 0
Views: 549
Reputation: 22688
You must run wxWidgets main loop from the same thread that initialized the library. If you want to run it in a thread other than main, it means that you can't use the standard IMPLEMENT_APP()
macro but must do the initialization yourself, e.g. by calling wxEntry()
manually.
Upvotes: 1