Can a single SetEvent() trigger multiple WaitForSingleObject()

前端 未结 4 1986
一向
一向 2021-02-09 00:35

This:

http://msdn.microsoft.com/en-us/library/ms686915(VS.85).aspx

Would seem to suggest not.

I have three processes communicating via pipes. Process A C

4条回答
  •  我寻月下人不归
    2021-02-09 01:04

    I hope this example can help you:

    handle1A = CreateEvent(LPSECURITY_ATTRIBUTES, ManualReset, InitialState, NAME)
    
    handle1B = CreateEvent(LPSECURITY_ATTRIBUTES, ManualReset, InitialState, NAME)
    
    handle2A = CreateEvent(LPSECURITY_ATTRIBUTES, ManualReset, InitialState, NAME+GetCurrentThreadId())
    
    handle2B = CreateEvent(LPSECURITY_ATTRIBUTES, ManualReset, InitialState, NAME+GetCurrentThreadId())
    

    A) if you create a event with the same NAME, every setEvent signaling all waitforsingleobjects

    SetEvent(handle1A) // Send signaling to handle1A and handle1B
    

    B) if you create a event whith a unique NAME, the setEvent only sends the signal to referenced handle

    SetEvent(handle2) // Send signling only to handle2A. The Id Thread is unique
    

提交回复
热议问题