【发布时间】:2023-03-21 23:05:01
【问题描述】:
我这里有一些代码,其中包含一个窗口类(使用 Nana C++)和一些网络线程。但是,我似乎无法以任何方式向用户输出。我尝试附加到文本框,使用消息框,打印到控制台,但它不会显示。这是 Nana 还是 Boost.Thread 的问题?
如果 Boost.Thread 有问题,我可以切换到 std::thread,但我认为它不会起作用。
void thread()//Let's say this function is started on a thread and the window is started on main
{
append(L"append test");
MsgBox(L"msgbox test"):
}
【问题讨论】:
-
在某些平台上,您只能从主线程绘制到 GUI。不过,使用 stdio 应该始终有效。
-
@west 所以我继续回答这个问题并找到了关于 Nana 的答案。您是在建议我从 Boost.Thread 更改为 nana::thread 或 nana::thread_pool?听起来很有趣,我会尝试一下。
-
不,我的想法是您需要通过这些线程进行通信,并且您需要某种方式使用消息传递或其他 IPC 机制进行通信,您可以创建消息框,但如果窗口未打开无法显示的同一线程。
标签: c++ multithreading boost nana