I have a C ++ console application that can be interrupted by pressing any key (implemented using kbhit ()), in which case it prints what it did and exits (or can be left to shut down (some entry ) and still prints feedback). I am making an aC # gui application for this console application (I am calling an exe file from a C # form), and instead of pressing any key on the keyboard, I use the "stop" button, which sends Environment.NewLine (or "\ n") to the redirected input and in a C ++ application now I need to use something other than kbhit () to work it. I tried using cin.get (), for example:
if (kbhit() || (cin.get() > 0))
stop_recording=true;
but cin.get () is a blocking function, and if I want the console application to run to the end, it does not close without pressing the stop button. Is there any function like cin.get () that doesn't actually block, or maybe another way to send "any key" from C # to my console application process?
source
share