Code: Select all
GetThread()->Wait();
But the docs of wxThread say -
Code: Select all
Regardless of whether it has terminated or not, you should call Wait() on a joinable thread to release its memory, as outlined in Types of wxThreads
Code: Select all
GetThread()->Wait();
Code: Select all
Regardless of whether it has terminated or not, you should call Wait() on a joinable thread to release its memory, as outlined in Types of wxThreads
Never thought about it. What are the pros and cons ?evstevemd wrote:Any reasona you are not using Detached Threads?
Code: Select all
If you call the Wait() function for a thread that has already finished it will cause problems
Code: Select all
Regardless of whether it has terminated or not, you should call Wait() on a joinable thread to release its memory, as outlined in Types of wxThreads
Code: Select all
The thread helper is used for a single background task, it cannot be started multiple times and the attempt will restart the task in a "dirty" way.
Code: Select all
So; Joinable threads are only good for single background tasks with constant, visual feedback. Detached threads are good for everything
Code: Select all
1) You should not call the Wait() function if the thread has already been released. Before you call the Wait() function you must check that the wait operation is valid or you might get into trouble.
No, the thread is only valid after a successful call to CreateThread(). wxThreadHelper is used to manage the lifecycle of the thread you create with CreateThread(), you should only Wait() when you need to halt program execution until the thread has finished. It is hard to figure out what is wrong with your code since you do not provide it but the error is either a result of calling Wait() from within the thread's context or a result of calling Wait() for at thread that cannot be waited for (not started, not created etc.).silver.moon wrote:Incase of JOINABLE threads inside wxThreadHelper "its released" only in wxThreadHelper destructor. So as long as the wxThreadHelper object is alive calling Wait should be always valid.