I am trying to create a program that runs multiple processes in separate threads. The program should have two methods of termination: after a specified amount of time the program terminates, or a pre-defined key combination will kill it. I have the setup in the Main thread to sleep for the amount of time and then abort the threads, but I can't seem how to set up another thread to check for if at anytime the user presses a key combination
This is what I started for the termination:
killKeyThread = new Thread(new ThreadStart(KeyCombo));
[names of various threads].Start();
DateTime future = DateTime.Now.addSeconds(_totalDurationSeconds);
while (future > DateTime.Now)
{
Thread.Sleep(1000);
}
[names of various threads].Abort();
I'm almost certain that the program needs to use a Windows Hooks in the thread, but I can't seem to set it up right.
Also if anyone has a better way of achieving this, it would be much appreciated