WaitForSingleObject not working with events, returning WAIT_FAILED every time RRS feed

  • Question

  • Hi,

    I was trying to use an event to track the shutdown status for all my threads when I encountered this problem. So I tried to simplify the problem as much as possible to see if I could see what was wrong but WaitForSingleObject always returns WAIT_FAILED. I've searched around a lot and I can't any answers what I'm doing wrong. Here's the simple code that still fails.

    HANDLE lEvent;
    lEvent = CreateEventA( FALSE, TRUE, FALSE, NULL ); 
    if ( lEvent == NULL || lEvent == INVALID_HANDLE_VALUE )
    	printf( "\n%d\n\n", GetLastError() );
    DWORD lValue = WaitForSingleObject( &lEvent, 0 );
    if ( lValue == WAIT_FAILED )
    	printf( "\n%d\n\n", GetLastError() );
    CloseHandle( lEvent );

    Any help is much appreciated.


    Andy =)

    • Moved by Kevin Woley Tuesday, September 8, 2009 4:36 PM to find the right events forum (From:Windows Events)
    Saturday, September 5, 2009 2:01 PM


All replies