C# Looping A Process Over And Over Until A User Presses A Key

Posted by Soo on Stack Overflow See other posts from Stack Overflow or by Soo
Published on 2010-05-19T14:21:11Z Indexed on 2010/05/19 14:40 UTC
Read the original article Hit count: 183

Filed under:
|
|
|

I have a schedule checker that needs to run until a user presses a key to make it stop.

My thoughts on doing this are as follows:

  1. The user starts the process
  2. Process runs every 10 seconds
  3. When the process is not running, Console.ReadLine(); gives the user the option to press "q" to stop the process

My approach would work fine except the user would have to wait however long the process takes to complete before being able to stop it. Is there any way to simultaneously run the process while being able to take a user input?

© Stack Overflow or respective owner

Related posts about c#

Related posts about readline