开发者

wxWidgets and boost::thread?

开发者 https://www.devze.com 2023-03-31 18:21 出处:网络
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 n

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

精彩评论

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