Working WaitForRequest method in cpp project