0

I am using WINAPI.

DWORD dwRc = ::WaitForMultipleObjects(3, aHandles, FALSE, pRedir->m_dwWaitTime);

My aHandles[2] signals before pRedir->m_dwWaitTime runs the required stuff and again runs the instruction:

DWORD dwRc = ::WaitForMultipleObjects(3, aHandles, FALSE, pRedir->m_dwWaitTime);

and process continues.

I want to modify the value of m_dwWaitTime. I want to determine the time between the start of aHandles[2] and when it signaled.

How do I do that?

Dean Seo
  • 5,486
  • 3
  • 30
  • 49
  • 1
    Store current time before starting to wait and after wait returns. Then calculate the difference. Note that wait time supplied to the function is the minimum wait time, in reality it can return after a longer interval. – user7860670 Jan 09 '18 at 09:48
  • how do i get the current time.This function just specifics if there is a timeout or not. – Saylee Lad Jan 09 '18 at 09:50
  • If you want a winapi solution then you can use `QueryPerformanceCounter`, if a c++ solution then `::std::chrono::high_resolution_clock`. – user7860670 Jan 09 '18 at 09:52
  • 2
    @VTT the wait functions operate at millisecond precision, so the performance counter API is overkill when `GetTickCount/64()` would suffice – Remy Lebeau Jan 09 '18 at 14:26
  • @RemyLebeau Even though wait functions take and tick functions return milliseconds typically neither of them operate at millisecond precision. – user7860670 Jan 09 '18 at 19:53
  • I tried using QueryPerformanceCounter [link](https://stackoverflow.com/questions/1739259/how-to-use-queryperformancecounter) but i get random timing – Saylee Lad Jan 10 '18 at 06:32
  • Then most likely you are using it incorrectly. Code at that question seems to be fine. – user7860670 Jan 13 '18 at 17:03

0 Answers0