Click here to Skip to main content
16,004,890 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

In my windows application i wanted to implement the functionality like when the user is not interacting with the application for more than 30 sec i wanted to close the application by default
can we do it with timer control? or any other way?
Please give some solution.


Thanks
ginnas
Posted
Comments
ZurdoDev 20-Nov-13 10:13am    
You would need to use a Timer control and keep track of what you consider "using."
johannesnestler 20-Nov-13 10:51am    
No, I don't think this "naive" Approach is "good".
Hard to keep track (even more with WinForms cause lack of Routed Events), hard to make it "performant" + the os already keeps track of Input events (idle) - just get the info there where the "screensaver" is looking (what Tadit Dash suggested in Solution 1)
Sergey Alexandrovich Kryukov 20-Nov-13 12:26pm    
Poor user... :-)
Instead of helping users to work, you are going to add hassles.
—SA
Yes, you are right. But I have seen the banking applications implement this kind of approach.
If you are inactive for sometime, the Session just expires. Even it happens for the Websites.
Sergey Alexandrovich Kryukov 21-Nov-13 1:27am    
Sure, that I can understand, but this is a very different thing. Session should expire, because this is an important security feature. But nothing should close application without user's consent. An application should wait for a user any time the user wants; and the user should be able to continue to work at any time. If session is expired, the user should be able to reconnect. Not a problem at all.
—SA

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Nov-13 12:30pm    
Why helping in meeting evil requirements? — please see my comment to the question. (I did not vote this time.)
—SA
Ya I understand you. :)
CPallini 20-Nov-13 13:28pm    
5.
Thanks a lot CPallini... :)
CPallini 21-Nov-13 3:19am    
You are welcome.
Monitor using the mouse move event. If the mouse does not move for the alloted time period, close the application.
This could slow down your application to an extent as on every move of the mouse, time difference will be calculated.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Nov-13 12:29pm    
The user can work using a keyboard along. But what's the difference? Anyone can also monitor keyboard activity as well.
This is not a problem. The problem is: this is a typical evil requirement — please see my comment to the question.
—SA
Abhinav S 20-Nov-13 22:18pm    
Agree. The ideal way of handling this would be monitoring at server side rather than client.
Close connections after a given timeout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900