Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WaitForMultipleObjects And notifying

WaitForMultipleObjects And notifying

Scheduled Pinned Locked Moved C / C++ / MFC
helpsecurity
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..

    V J 2 Replies Last reply
    0
    • J justin223

      Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      What do you mean "only detects that signal state randomly?" WaitForMultipleObject signals "Either any one or all of the specified objects are in the signaled state" according to MSDN. Kuphryn

      J 1 Reply Last reply
      0
      • V valikac

        What do you mean "only detects that signal state randomly?" WaitForMultipleObject signals "Either any one or all of the specified objects are in the signaled state" according to MSDN. Kuphryn

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        WaitForMultipleObjects wait for any of the events to get signalled. But it only works sometimes when I signals the hNewDataEvent, i want to know why. The event is created with the GUI thread and is passed to the workerthread when I create it.

        V 1 Reply Last reply
        0
        • J justin223

          WaitForMultipleObjects wait for any of the events to get signalled. But it only works sometimes when I signals the hNewDataEvent, i want to know why. The event is created with the GUI thread and is passed to the workerthread when I create it.

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #4

          It still would not become signaled even when you sign one or other events? Make sure the other handles are valid. Kuphryn

          J 1 Reply Last reply
          0
          • V valikac

            It still would not become signaled even when you sign one or other events? Make sure the other handles are valid. Kuphryn

            J Offline
            J Offline
            justin223
            wrote on last edited by
            #5

            kuphryn wrote: It still would not become signaled even when you sign one or other events? Make sure the other handles are valid. well.. That was the first thing I checked. It's valid alright.

            1 Reply Last reply
            0
            • J justin223

              Hello I've got a class that contains an event called hNewData that is manually resetted, initial not signalled and no security attributes. The event is used to signal my workerthread when some new data should be sent. In the workerthread I wait for some diffrent events: hEvents[0] = pTP->hStopEvent; hEvents[1] = pTP->hNewDataEvent; hEvents[2] = osWriter.hEvent; hEvents[3] = osReader.hEvent; hEvents[4] = hDoReadEvent; pTP is a point to a struct that is passed to the thread when I create it. My problem is that WaitForMultipleObjects only detects that signal state randomly, and I have no f****n clue why. Starting to get desperate here, so please help. The class is a socket communication class..

              J Offline
              J Offline
              Joel Lucsy
              wrote on last edited by
              #6

              so you have something like the below snippet? ret = WaitForMultipleObject( 5, hEvents, FALSE, INFINITE ); if (ret == (WAIT_OBJECT_0 + 1)) //dosomething the key points here are: 1) passing FALSE so that it doesn't have to wait for all objects 2) using INFINITE so that it blocks until an event is signalled and won't timeout, and 3) correctly determining which has become signalled. Since you didn't provide any code I can't really say what's the problem. Joel Lucsy

              J 1 Reply Last reply
              0
              • J Joel Lucsy

                so you have something like the below snippet? ret = WaitForMultipleObject( 5, hEvents, FALSE, INFINITE ); if (ret == (WAIT_OBJECT_0 + 1)) //dosomething the key points here are: 1) passing FALSE so that it doesn't have to wait for all objects 2) using INFINITE so that it blocks until an event is signalled and won't timeout, and 3) correctly determining which has become signalled. Since you didn't provide any code I can't really say what's the problem. Joel Lucsy

                J Offline
                J Offline
                jgauffin
                wrote on last edited by
                #7

                I've solved it. I had named my event and that fucked everything up.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups