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.

你可能感兴趣的:(thread,processing,application,behavior,idea,class)