mattKnight
Programmer
Hi,
relative newbie to C++, even newer to multi-threading; so please be gentle!
I am currently investigating (playing with) multi-threading, synchronisation etc.
my query is this...
relative newbie to C++, even newer to multi-threading; so please be gentle!
I am currently investigating (playing with) multi-threading, synchronisation etc.
my query is this...
Code:
DWORD WINAPI ListenerSocket::WorkerThreadProc(LPVOID lpParameter)
{
myClass *pThis;
pThis = reinterpret_cast<myClass *>(lpParameter);
// pThis now allows access to class methods & member variables from this static method
while(!pThis->mbThreadStop)
{
long lRet;
lRet = myBlockingCall(pThis->GetMyInfo());
// TO DO
// Other useful code relying on return from blocking call
}
}
I am sure you get the idea!
Suppose I want to kill the thread, whilst the thread is blocked waiting for myBlockingCall?
If mbThreadStop is set true, the thread will exit after myBlockingCall, which may not be the desired response!
I could use TerminateThread(), but isn't that a bit "brute force" or am I looking for a neat solution to a problem that can only be solved by the bruteforce approach.
I am sorry, but this is a little abstract, the above code is an example only.
Thanks!
Take Care
Matt
If at first you don't succeed, skydiving is not for you.