Reputation: 830
I want to read multiple lines of user input from the console, but also allow termination of input with an escape sequence like CTRL-C. My problem is canceling the last call to ReadLine() when the escape sequence is pressed. I've tried multithreading and forcing the thread to close, but my problem is getting the last line of user input. When the escape sequence is pressed, the last line is lost and I can't get it back using ReadLine() from the main thread. If I input something like this:
Input
Input2 [CTRL-C],
I only get 'Input\n'. Is there a way to get multiple lines of input, but capture the last line when the escape sequence is pressed?
Upvotes: 1
Views: 2617
Reputation: 8551
As suggested in my comment above, it apparently works to:
Upvotes: 3