Well, the caption of the question might be a little off, but I didn't figure any better, so here it goes:
I would like to read what user typed 'so far', I need it to work like this: User inputs some required data and then is asked if he/she wants the full progress output or just the results.
Of course, I could call ReadLine and see what he/she writes, but I'd like to have it neater - after the final data input, he/she would be asked for the detailed info. The program would wait like 2sec and then 'read' what the user wrote. If nothing, the program would run normally, if the required string, the program would provide detailed calculations.
I hope it's clear
Thanks for answers
E: Another way would be simulating a enter key press after those 2 seconds, so either this or that would be nice.
ANSWER For anyone interested in the working code.
bool timepassed = false;
bool detailmode = false;
long start = System.Environment.TickCount;
while (Console.KeyAvailable == false) // This loop will quit when KeyAvailable is true, i.e. a key is pressed (OR by the break command below)
{
Console.Write("."); // write dot every 100ms to indicate progress
System.Threading.Thread.Sleep(100);
if (System.Environment.TickCount - start > 1250){
timepassed=true; // if more than 1250ms passed, set flag break
break;
}
}
detailmode = !timepassed; // if time didnt pass, then user did press a key (and vice versa)->set detailmode
if (detailmode == true)
{
Console.ReadKey(true); // hide the pressed key
Console.WriteLine("\n\n-Detailni mod-"); // notify user about detailed mode
}