The console doesn't define those events. You can simulate something by using Console.ReadKey
. You'd have to define your own events, then:
var key = Console.ReadKey();
// create event parameters and dispatch the event
Obviously, Console.ReadKey
blocks on the console. You can put that in a thread if you want, and dispatch the event from there. Be advised, though, that the event notification will come in on a separate thread (i.e. not the main thread).
Also, you can't have two different threads reading from the same console. Well, you can, but the results are unpredictable. For example, if your background thread is waiting on a ReadKey
and another thread calls Console.ReadLine()
, there's no telling where the input will end up.