July 22th Wednesday (七月 二十二日 水曜日)

 A common problem users experience with wxThread is that in their main thread they will check the thread every now and then to
see if it has ended through wxThread::IsRunning, only to find that their application has run into problems because the thread is
using the default behavior and has already deleted itself. Naturally, they instead attempt to use joinable threads in place of
the previous behavior.

  However, polling a wxThread for when it has ended is in general a bad idea - in fact calling a routine on any running wxThread
should be avoided if possible. Instead, find a way to notify yourself when the thread has ended. Usually you only need to notify
the main thread, in which case you can post an event to it via wxPostEvent or wxEvtHandler::AddPendingEvent. In the case of secondary
threads you can call a routine of another class when the thread is about to complete processing and/or set the value of a variable,
possibly using mutexes and/or other synchronization means if necessary.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值