locked
Synchronization function(WaitForSingleObjectEx,CreateEventExW,ResetEvent) problem in Metro Style

    Question

  • According to msdn documentation, several synchronization function like WaitForSingleObjectEx, CreateEventExW, ResetEvent, SetEvent is supported in metro style apps.In CreateEventExW() function now allowed to define access right through its fourth parameter.

    WaitForSingleObjectEx() needs SYNCHRONIZE access rights while ResetEvent/SetEvent  function needs EVENT_MODIFY_STATE access rights.

    So, How we can use this two function for the same event simultaneously??? Is it bug ?

    Can I use this synchronization function to synchronize PPLTASK/APC in metro ? If not how we can block an asynchronous operation (if required) in metro style app??

    Here is my pseudo code scenario in WinRT:

    HANDLE htest=CreateEventEx( NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS );

    ResetEvent(htest);

    task<void>(stmsocket->ConnectAsync(remoteHostName, remoteServiceName, SocketProtectionLevel::PlainSocket)).then([this] (task<void> previousTask) {
            try{     SetEvent(htest); //Success   }

    catch(Exception e) {       SetEvent(htest); //Failure    }

    DWORD dwRet = WaitForSingleObjectEx(htest, INFINITE, TRUE);

    In this case WaitForSingleObjectEx() wait for ever. Why??? Is WaitForSingleObjectEx usable for APC ?


    Wednesday, August 1, 2012 12:18 PM

Answers

All replies