none
Can SetEvent be used to send multiple events at the same time...? RRS feed

  • Question

  • I have Three processes. Process A Creates two different events.
    Process B & C each uses WaitForSingleObject and wake up on specific event from Process A.

    For Ex: Process A create events, "Start_process_B" & "Start_process_C"
    and Process B wakes up with the event "Start_process_B" from Process A
    and Process C wakes up with the event "Start_process_C" from Process A


    ---Process A
    static HANDLE aEvent[10];
    aEvent[0] = CreateEvent(NULL, TRUE, FALSE, TEXT("Start_process_B")); 
    aEvent[1] = CreateEvent(NULL, TRUE, FALSE, TEXT("Start_process_B")); 

    while(1)
    {
    SetEvent(aEvent);                            //Any solutions for sending multiple events at the same time..?
    ...
    }

    ---Process B
    static HANDLE bEvent;
    bEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_B"));

    while(1)
    {
    WaitForSingleObject(bEvent, INFINITE);
    ...
    }

    ---Process C
    static HANDLE cEvent;
    cEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_C"));

    while(1)
    {
    WaitForSingleObject(cEvent, INFINITE);
    ...
    }

    Wednesday, September 25, 2019 1:45 PM

Answers

  • SetEvent takes a single HANDLE to one event object for its parameter, not an array.  If you want to call it on each handle in an array use a loop.

    If you want to release more than one process you can use a manual reset event and have Process B and Process C wait on that event.  When Process A calls SetEvent then both Process B and Process C will exit their wait states.



    Wednesday, September 25, 2019 2:26 PM