Thread: Taking input while calculating

  1. #1

    Taking input while calculating

    Hi Programmers!

    I'm writing a program where the program is essentially calculating something for an infinite amount of time. I want to be able to check for user input while the program is calculating.

    Due to the structure of the program, I figure the best was to do this is to call some sort of CheckForInput() function on (say) every 2000th iteration of the function that is doing the calculating so it checks like every 1/50th of a second.

    Actually its not really a user typing something. It's going to be another windows program talking trough some pipe to my program's stdin, so it can't use kbhit. How can I determine if it hasn't "typed" (for lack of a better word) something so I can break out of the CheckForInput function.

    I need some pretty detailed info here if anyone has the time.


  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    If you are using windows, you could try using a thread. One thread would continually check for input while the main process just runs the calculating function.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  2. large program code ,please help
    By Ash1981 in forum C Programming
    Replies: 14
    Last Post: 01-30-2006, 06:16 AM
  3. taking user input as title for output file...
    By perkins in forum C++ Programming
    Replies: 4
    Last Post: 12-26-2005, 06:36 PM
  4. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 11:28 PM
  5. Taking Voice input
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 01-30-2002, 01:34 PM