The following code is causing the console to close (exit code 0, telling me that the program is finished). Weird thing is: it doesn't even go to the switch (choice)
statement. The debugger shows me that the Console.ReadLine()
statement is reached, but not the switch(choice)
.
Please note:
- The console closes after I enter a number (1 or 2) and hit Enter.
- I set breakpoints on the switch statement and it does not reach this line of code. I verified that using the debugger. It's closing the cmd right after I hit enter. This seems to be the last line of code reached.
- I've used that kind of menu in another class of my program without any issues whatsoever.
- I'm calling this method (PostTestMenu()) from a System.Threading.Timer
Why would the program stop even though there is still code to be executed and the debugger clearly states that it doesn't even reach the subsequent code?
protected void PostTestMenu ()
{
string choice;
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine("############## What next #############");
Console.WriteLine("Repeat 1");
Console.WriteLine("Next 2");
choice = Console.ReadLine();
switch (choice)
{
case "1":
Setup();
break;
case "2":
program.Hauptmenue();
break;
}
}