Oliver Sokol wrote:Hey, thanks for the reply.
Well I would want it to be a monitoring thing, so for example to observe a watch, and every time it sees that it is a specific time it will execute an if statement. Essentially it is not yet important where the input comes from more interested in learning how to make a loop that will continuously and repeatedly look for a value and continue even after it finds it.
Again thanks for replying.
Since it isn't important where it comes from, let's assume the handling of the value takes no time to do.... You could use something more or less like this:
In reality, everything depends on how fast the input comes, how much time what you have to do with the input takes, even whether you're allowed to miss some inputs. For starters look up the idea of a buffer. Some part of the system would put new input in the buffer and when you went back to the loop you would check the buffer to see if anything got put in there while you were off playing with the last input. Keyboard input is usually already buffered for example, so that's why I mentioned keyboard before. Rarely you might need two threads, with one reading input and buffering it and the other handling the buffered input. So you see, it really does depend on what you want to do.