Taking input while calculating

This is a discussion on Taking input while calculating within the C Programming forums, part of the General Programming Boards category; Hi Programmers! I'm writing a program where the program is essentially calculating something for an infinite amount of time. I ...

  1. #1
    Unregistered
    Guest

    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.

    Thanks.
    DRM

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    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

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