开发者

wxWidgets and boost::thread?

I want to use boost to do background networking stuff in a loop while wxWidgets processes the GUI开发者_开发技巧. I just started using wxWidgets so my first idea was to just start in the thread with networking loop inside OnInit of the app, but that wasn't a really good idea as the ap cannot continue running as the thread stops it.

How does one use boost::thread for multithreading and wxWidgets library together?


you can start your networking part in OnInit() if you want but the listener needs to fork out to a different thread.having an io_service and at least one boost::thread that calls run on the io_service should do the trick.your network stuff will be carried on by the thread(s) calling io_service::run() and the master thread can return to doing wxWidgets stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜