Thread: A non-blocking sleep whit visual studio c++

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    A non-blocking sleep whit visual studio c++

    I'am trying to make a piece of code which will work as a non-blocking sleep.

    I tried to use the select, but it does not under visual c++

    Does any one have an idea about how i can do this ?

  2. #2

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    A blocking function means it returns when it's got what it came for, even if it has to wait to achieve that. So a non-blocking function allows your code to instantly continue execution. The purpose of a sleep function is to temporarily halt your program, therefore you cannot have a function that continues execution and sleeps at the same time.

    Unless you have a quantum computer... =o
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    2
    And what about a delay function, then?

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I guess the question is, what do you want to have happen that Sleep() doesn't do for you?

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Sounds like you want to continue processing/normal app functioning while waiting for some event to occur (or process to finish).

    Have you looked at using a thread with WaitForSingleObjectEx()?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM