thready
asked on
CreateThread & WaitForSingleObject
Hi Experts,
I'm creating a thread like this:
DWORD dwThreadID;
m_hMyThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) MyThProc, (LPVOID*) this, 0, &dwThreadID);
Later on, I'm waiting on this thread to finish, with this:
WaitForSingleObject(m_hMyT hread, INFINITE);
It seems to be deadlocked. Is this because this just won't work? Or is it because something else in my code somewhere is likely deadlocking?
Thanks!
Mike
I'm creating a thread like this:
DWORD dwThreadID;
m_hMyThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) MyThProc, (LPVOID*) this, 0, &dwThreadID);
Later on, I'm waiting on this thread to finish, with this:
WaitForSingleObject(m_hMyT
It seems to be deadlocked. Is this because this just won't work? Or is it because something else in my code somewhere is likely deadlocking?
Thanks!
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thanks Mike.
i saw the following by rereading the question:
LPVOID already is void*. so LPVOID* actually is void** (what doesn't make any difference to the call though).
you could omit the cast at all since the compiler always would allow an implicit cast to void* . the compiler even accepted the pointer to pointer as a valid argument for void* without warning.
Sara
i saw the following by rereading the question:
(LPVOID*) this
LPVOID already is void*. so LPVOID* actually is void** (what doesn't make any difference to the call though).
you could omit the cast at all since the compiler always would allow an implicit cast to void* . the compiler even accepted the pointer to pointer as a valid argument for void* without warning.
Sara
ASKER
I just saw your last comment- double awesome. Thanks! :-)
ASKER
I actually had a silly bug which prompted this question. But I always get good stuff on here.... :)
Cheers,
Mike