I know that this question has already been asked on How to detect my application is idle in c# (form covered)?, and on How to detect my application is idle in c#? But I couldn't find an optimal solution to my problem in those posts.
I have an application which needs to logout if a certain time has passed. We are currently using getLastInput method which tells the number of ticks from the last user input. We subtract this time from the current time, and converting this time using fromMiliseconds we check if the time passed from the last input is larger than our threshold, and if so we log out.
The problem is that the getLastInput method returns quickly and the diff doesn’t reach the threshold despite the fact no input is entered to the application.
I think that hooking into mouse/key events through windows will be slow, since every time an input occurs we will need to reset the timer.
I will be glad to hear your ideas.