Hi!
I'd like to write a program, which makes an infinite loop doing { perform_operations(); sleep(for_minute);}. The program should always monitor the stardard console input, if user inserts a command, program wakes up from his sleep and handles the command.
I wrote the code using Asynchronous I/O multiplexing, however there is one problem: I would like the program to be more server-like, which means that the command is handled (and the program is interrupted) only if user inserts full command and presses enter. The code I wrote, when I do only one keypress holds and waits for message, while I'd rather want it to not stop his loop until enter is pressed.
I'm not sure how you intend to interrupt the task you intend to run on timeout.
The loop isn't quite right. Rather than while (true), you might want to consider while (WaitForMultipleObjects, where you'd terminate if a terminate event is signalled. You'd signal it in your Stop Handler.
You can use Overlapped I/O to do the ReadFile. You just add the overlapped event to the list of things to wait for and get signalled when the read completes. When that signals, you check the buffer and process the input command.