util.cpp 430 B

1234567891011121314151617181920212223
  1. #include "Main.h"
  2. void WaitForEvent(HANDLE hEvent, DWORD msMaxWaitTime)
  3. {
  4. // DWORD i;
  5. MSG msg;
  6. const unsigned long eachWait = 10;
  7. unsigned long totalWait = 0;
  8. while (WaitForSingleObject(hEvent, eachWait) == WAIT_TIMEOUT)
  9. {
  10. while (PeekMessage(&msg, (HWND) NULL, 0, 0, PM_REMOVE))
  11. {
  12. //TranslateMessage(&msg);
  13. DispatchMessage(&msg);
  14. }
  15. totalWait += eachWait;
  16. if (totalWait >= msMaxWaitTime)
  17. break;
  18. }
  19. }