If you are going to use WaitForSingleObject then you can NOT use _beginthread. You need _beginthreadex. _beginthread auto calls _endthread and CloseHandle() when the thread terminates. WaitForSingleObject has undefined results if CloseHandle() is called on a handle while you are waiting on it...