0

I'm eager to know how you generally would timeout if a user is idle in C#. There are some "Q/A"s about how to timeout after a certain time, but that is not what I ask. Assume there is a console.readline() waiting for a user to put some characters. I want to timeout if user is not entering any character within 5 seconds. But if the user types a random character e.g. "D", then waits 2 seconds, enters "A" waits 3 seconds, and go on like that the app should not timeout since the user is actively interacting with the program within less than 5 seconds. I hope my question is clear enough, if not feel free to ask for more clarification.

The other question here is not about timing out when user is idle, it just simply times out after some seconds, my question is about detecting idle user. That is when user is not actively interacting with the console of my application!

Damon
  • 69
  • 6
  • 5
    Possible duplicate of [How to add a Timeout to Console.ReadLine()?](https://stackoverflow.com/questions/57615/how-to-add-a-timeout-to-console-readline) – Romen Jul 25 '19 at 19:38
  • That is not timeout when user is idle, it just simply times out after some seconds, my question is about detecting idle user. – Damon Jul 25 '19 at 19:54
  • 1
    Sorry, the question title is technically answered by that duplicate. You can also determine if the user has gone idle with [GetLastInputInfo](https://stackoverflow.com/questions/1037595/c-sharp-detect-time-of-last-user-interaction-with-the-os). – Romen Jul 25 '19 at 20:00
  • I used the same title with a slight difference at the end because it was the simplest code for me to understand how this timeout works. – Damon Jul 25 '19 at 20:14
  • I still need a respond with some code regarding this, anyone willing to help? – Damon Jul 26 '19 at 17:40
  • Can you update your question with the code that you have attempted already? Between the two SO answers I have linked in these comments there is enough information to implement what you are asking for. – Romen Jul 26 '19 at 18:15

0 Answers0