您的位置:首页 > 其它

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

2009-07-16 16:19 417 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: