WaitOne with 0 as timeout value

This is a discussion on WaitOne with 0 as timeout value within the C# Programming forums, part of the General Programming Boards category; Hello everyone, 1. I have checked MSDN document, http://msdn2.microsoft.com/en-us/lib...t0(VS.80).aspx it does not cover what is the function of WaitOne if ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    WaitOne with 0 as timeout value

    Hello everyone,


    1.

    I have checked MSDN document,

    http://msdn2.microsoft.com/en-us/lib...t0(VS.80).aspx

    it does not cover what is the function of WaitOne if we assign 0 as the timeout parameter.

    I think the function of assigning 0 is to check whether the signal is set or not, and it will be returned immediately, right?

    2.

    If WaitOne (0, true) returns true, it means the signal is set or not set?


    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    1. Yes, I would think that zero means "do not wait for this to happen". I haven't used this particular function (or programmed C# more than once, really), but it follows other "wait-with-timeout" functions in Windows API - and it seems like the obvious thing to happen in general - the only other option for 0 to mean "wait forever", but "-1" is used for that purpose, so it makes no sense to have two values meanign "wait forever" - so as a conclusion, zero means "don't wait", just check the result right now and tell me what it was.

    2. Yes.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Mats,


    Question answered.

    Quote Originally Posted by matsp View Post
    1. Yes, I would think that zero means "do not wait for this to happen". I haven't used this particular function (or programmed C# more than once, really), but it follows other "wait-with-timeout" functions in Windows API - and it seems like the obvious thing to happen in general - the only other option for 0 to mean "wait forever", but "-1" is used for that purpose, so it makes no sense to have two values meanign "wait forever" - so as a conclusion, zero means "don't wait", just check the result right now and tell me what it was.

    2. Yes.

    --
    Mats

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WaitOne exitContext
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 04-23-2008, 12:53 AM
  2. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  3. how to setup C# TCPClient timeout
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-13-2007, 12:09 PM
  4. rsh timeout
    By jlai in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 07:18 AM
  5. connect timeout
    By X PaYnE X in forum Networking/Device Communication
    Replies: 8
    Last Post: 05-14-2005, 09:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21