locked
WaitForMultipleObjectsEx always return WAIT_FAILED in C++/CX

    Question

  • Hi 

    I created two event in C++/CX as following:

    	endEvent[0] = CreateEventEx( NULL, L"e0", 0, 0);	
            endEvent[1] = CreateEventEx( NULL, L"e1", 0, 0);

    then in main thread I want to wait for signaling for specific time.

    	auto result = WaitForMultipleObjectsEx(
    		2,
     		endEvent,
     		true,
     		2000,
    		false);

    but the result is always is WAIT_FAILED. Could anyone tell me what am I missing?



    Best Regards. Pooya Eimandar.

    Friday, July 12, 2013 9:05 AM

Answers

  • In case of Windows Store apps, always try to use Unicode version of APIs.

    It seems to me that lack of permission in access on event object.

    Try by setting EVENT_ALL_ACCESS as desired access mask for the event object.

    CreateEventExW( NULL, NULL, NULL, EVENT_ALL_ACCESS );

    For more details Synchronization Object Security and Access Rights

    Friday, July 12, 2013 4:42 PM

All replies

  • Check GetLastError; Do you executing your above code from UI thread?

    If yes, you have to go into a different worker thread. Since, in windows store apps, UI always should be responsive and UI thread does not allow any blocking, any waiting/time consuming operation should belongs into worker thread.

    Friday, July 12, 2013 3:36 PM
  • Hi

    Thanks for your reply.

    I tested in both UI thread and worker thread, and nothing changed.

    The GetLastError return error number 5, which means ERROR_ACCESS_DENIED. What is missing?


    Best Regards. Pooya Eimandar.

    Friday, July 12, 2013 4:30 PM
  • In case of Windows Store apps, always try to use Unicode version of APIs.

    It seems to me that lack of permission in access on event object.

    Try by setting EVENT_ALL_ACCESS as desired access mask for the event object.

    CreateEventExW( NULL, NULL, NULL, EVENT_ALL_ACCESS );

    For more details Synchronization Object Security and Access Rights

    Friday, July 12, 2013 4:42 PM
  • Thanks a lot. It works. ;)

    Best Regards. Pooya Eimandar.

    Saturday, July 13, 2013 7:06 AM