I'm writing a simple console application with a menu that has some choices. Every time you select an option it should:
ask for a number,
output the result,
pause the app until a key is pressed so the user can read the data printet out,
clear the screen and display the menu again
system("pause") doesn't work because it's launched in a seperate thread and is not in sync with the application (sometimes its way behind the app and sometimes ahead of the execution(!) O_o )
SleepEx() doesn't seem to be able to do what I want.
WaitForInputIdle() doesn't work since console applications doesn't have a message queue.
What can I do to make this work? I hate those system calls to be so out of sync with the app!
And no, I don't want to use an infinite while loop untill a char is pressed as it would take 100% CPU.
Not having a backup on Earth and another on the moon and another on Mars is also a redundancy failure.
Not having a backup in another galaxy is a redundancy failure
How do people work?
You have 1 PC, 1 Laptop and 1 iPhone.
How do you synchronize your photos, videos and documents between 3 different devices? Of course, it's with the cloud, right?
Are you going to use an external SSD to share files between your PC, Laptop and iPhone?
"New" Outlook is not even a mobile app (mobile app has Unified Inbox at least), this is just their web app with an added ability to use email account other than Microsoft's.
Question
Andos
This has annoyed me for hours if not days. :(
I'm writing a simple console application with a menu that has some choices. Every time you select an option it should:
ask for a number,
output the result,
pause the app until a key is pressed so the user can read the data printet out,
clear the screen and display the menu again
system("pause") doesn't work because it's launched in a seperate thread and is not in sync with the application (sometimes its way behind the app and sometimes ahead of the execution(!) O_o )
SleepEx() doesn't seem to be able to do what I want.
WaitForInputIdle() doesn't work since console applications doesn't have a message queue.
What can I do to make this work? I hate those system calls to be so out of sync with the app!
And no, I don't want to use an infinite while loop untill a char is pressed as it would take 100% CPU.
Anyone? :(
Edited by AndosLink to comment
https://www.neowin.net/forum/topic/462358-c-console-function-to-wait-for-input/Share on other sites
7 answers to this question
Recommended Posts