I have a c++ console application which has an option to be interrupted by pressing any key (implemented by using kbhit()) and in that case it prints what it has done and exits (or can be left to finish the work(some recording) and still prints feedback). I am making a c# gui application for that console application (I'm calling exe file from c# form) and instead of pressing any key on the keyboard, I am using a "stop" button which sends Environment.NewLine (or "\n") to the redirected input and in the c++ application I now have to use something different from kbhit() for it to work. I tried using cin.get(), like:
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 won't close without pressing the stop button. Is there any function similar to cin.get() that actually isn't blocking, or maybe a different way to send "any key" from c# to my console application process?