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#
  4. About AutoResetEvent

About AutoResetEvent

Scheduled Pinned Locked Moved C#
csharpquestion
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.
  • B Offline
    B Offline
    Bob_Sun
    wrote on last edited by
    #1

    In .NET manual, AutoResetEvent.WaitOne() is [C#] public virtual bool WaitOne(); My question are : 1.In what case will "false" be returned? 2.Is it necessary to look at the return value of WaitOne? Thnak you!

    G 1 Reply Last reply
    0
    • B Bob_Sun

      In .NET manual, AutoResetEvent.WaitOne() is [C#] public virtual bool WaitOne(); My question are : 1.In what case will "false" be returned? 2.Is it necessary to look at the return value of WaitOne? Thnak you!

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      bool WaitOne() is true if the current instance receives a signal. It will never be false since it won't return if it is unsignaled.

      B 1 Reply Last reply
      0
      • G George L Jackson

        bool WaitOne() is true if the current instance receives a signal. It will never be false since it won't return if it is unsignaled.

        B Offline
        B Offline
        Bob_Sun
        wrote on last edited by
        #3

        Thank you for your reply. I have also checked a lot these days, and come to the same conclusion Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()). I have a problem that WaitOne() returned before it is Set() at another thread. As it happens not so frequently, I still don't know the reason. I my app, except for the main thread, all threads are started by BeginInvoke. Thnak you! -- modified at 2:07 Thursday 30th March, 2006

        G 1 Reply Last reply
        0
        • B Bob_Sun

          Thank you for your reply. I have also checked a lot these days, and come to the same conclusion Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()). I have a problem that WaitOne() returned before it is Set() at another thread. As it happens not so frequently, I still don't know the reason. I my app, except for the main thread, all threads are started by BeginInvoke. Thnak you! -- modified at 2:07 Thursday 30th March, 2006

          G Offline
          G Offline
          George L Jackson
          wrote on last edited by
          #4

          Bob_Sun wrote:

          Would tell me if there are some difference between using AutoResetEvent' WaitOne/Set in forground-thread (started by Thread.Start() )and background thread(started by BeginInvoke()).

          I believe there is no difference. Anyway, you need to initialize the AutoResetEvent as unsignaled before using it: AutoResetEvent are = new AutoResetEvent(false); It also needs to be in the same scope as the thread waiting for the signal.

          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