문제

Is there a way to know how much time passed from when I called WaitForSingleObject function untill it returned?

or that the only way of knowing is by using some kind of a timer?

도움이 되었습니까?

해결책

Just store current time before calling WaitForSingleObject(). Then compare to time when it returns.

From http://msdn.microsoft.com/en-us/library/windows/desktop/ms725473(v=vs.85).aspx - select a function to retrieve time.

다른 팁

You will need to use a timer if you need to track that. The other alternative (although you won't get exact time, a timer would be better) is to call WaitForSingleObject with a small timeout value. You can check the return code to see if it is WAIT_TIMEOUT. If it is, then increment your time count by the timeout value.

GetTickCount() before and after the call. Watch out for DWORD wrap-around.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top