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. Simple WaitForSingleObject question

Simple WaitForSingleObject question

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 2 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I created an event With the Following parameters CreateEvent(NULL,FLASE,FALSE,NULL); From what I understand the third parameter says what the initial state of the object is Signaled or NON signaled if it is FALSE non signaled the first time I executed the WaitForSingleObject my thread will return and in addition set the object to signaled Meaning all threads will have to wait till I call SetEvent Thing is the first time around the executing thread never returns

    M 1 Reply Last reply
    0
    • F ForNow

      Hi I created an event With the Following parameters CreateEvent(NULL,FLASE,FALSE,NULL); From what I understand the third parameter says what the initial state of the object is Signaled or NON signaled if it is FALSE non signaled the first time I executed the WaitForSingleObject my thread will return and in addition set the object to signaled Meaning all threads will have to wait till I call SetEvent Thing is the first time around the executing thread never returns

      M Offline
      M Offline
      Midi_Mick
      wrote on last edited by
      #2

      I think you've got the meaning of "signalled" the wrong way around. The wait function will return only when the event is signalled. An auto-reset event will automatically reset the event to non-signalled when it returns, and manual reset event will not. Use the SetEvent to release other threads, or the ResetEvent to block other threads. Think of the event of some operation that has to happen in your code. Other threads need to wait for that operation to complete. Once it has been completed, you signal the other threads that it is ok to proceed.

      Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

      F 1 Reply Last reply
      0
      • M Midi_Mick

        I think you've got the meaning of "signalled" the wrong way around. The wait function will return only when the event is signalled. An auto-reset event will automatically reset the event to non-signalled when it returns, and manual reset event will not. Use the SetEvent to release other threads, or the ResetEvent to block other threads. Think of the event of some operation that has to happen in your code. Other threads need to wait for that operation to complete. Once it has been completed, you signal the other threads that it is ok to proceed.

        Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Okay how about the second parameter to CreateEvent if that is FALSE does that mean that after a signal'ed event returns right away from WaitForSingleObject Windows will Automatically turn the event to NON signalled

        M 1 Reply Last reply
        0
        • F ForNow

          Okay how about the second parameter to CreateEvent if that is FALSE does that mean that after a signal'ed event returns right away from WaitForSingleObject Windows will Automatically turn the event to NON signalled

          M Offline
          M Offline
          Midi_Mick
          wrote on last edited by
          #4

          Yes, it does. bManual = FALSE means that it is an Automatic ResetEvent after a wait operation.

          Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

          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