I have a thread (detached thread) which will create a socket connection, send a request and wait for the answer.
Once the answer arrives, it is processed. In case the answer does not arrive in time, we will no longer wait on it.
That means that the Entry() function of the thread (which created the thread and waited for some time (semaphore with timeout) will run till the end. One of the last steps in the thread entry function is to call Destroy() on the socket
Something like this :
Code: Select all
Entry()
{
// create socket 'MySocket'
// do some stuff
MySocket->Destroy();
}
However after the Destroy() the thread can finish, and will be automatically freed/deleted by wx, but what if after that deletion one of those pending socket events is processed. But it's handler (the thread) no longer exists.
Is there a way, to know/wait when all events of that Socket are processed, and only then allow the thread to finish ??