Wait set time for user input C# console app

c#, user-input, wait

Solution

Set a 10 second timer off.

Fire an event when the timer expires.

In the event handler proceed with the "auto run" section.

If the user hits a key before the timer expires, kill the thread.

The `Timer` class page on MSDN has an example of a timer waiting for a set period.

Problem

For a Console app, I need to know how to wait at set amount of time (about 10 seconds), for a user to input a key or set of keys, before proceeding with an 'auto run' portion of the application. This is bugging me because I can't quite figure out how the timer works, or threading.sleep, what should I use? Been googling all day. some psuedocode: 1.app opens 2.app waits 10 secs for user to hit the "k" key. 3.if user hits k, go to 4. if user does not, go to 5. 4.run a function(open a form) 5.run a function(do something) I bet its simple, I just don't understand whats going on.

Original source

Related problems