Time passed till WaitForSingleObject returned

二次信任 提交于 2019-12-11 08:18:24

问题


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?


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/12936332/time-passed-till-waitforsingleobject-returned

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!