Detecting idle time in .NET CompactFramework Applications

£可爱£侵袭症+ 提交于 2020-01-06 07:17:09

问题


We want to activate a process if the user does not interact for 2 mins with our compact framework application running on our custom built devices.

I found an excellent C# sample code of Code Project(http://www.codeproject.com/KB/cs/ApplicationIdle.aspx) but it is not supported for compact framework as this code depends on Timers Class and Application.Idle events.

Can someone suggest me how to detect idle time?


回答1:


This blog entry is exactly what you need.

(Archived version: http://web.archive.org/web/20090615073146/http://blog.opennetcf.com/ctacke/2009/05/19/DetectingApplicationIdle.aspx)




回答2:


I haven't used the .NET Compact Framework in nearly 4 years, but maybe this is something that you could P/Invoke? Or maybe OpenNetCF have something for this in their library? (that one saved me a couple of times back in the days.) I just did a quick search over there and they do have a class for Timers, you might want to check it out and see if it can help: http://www.opennetcf.com/library/sdf/




回答3:


Differences Between the .NET Compact Framework and the .NET Framework:

Timers The Start and Stop methods for a System.Timers.Timer object are not supported, but you can start and stop timing by setting the Enabled property of a System.Windows.Forms.Timer object to true or false.

You can also use System.Threading.Timer

Supported in: 3.5, 2.0, 1.0 .NET Compact Framework

You can use a Timer to detect idle activity like so: every time the user interacts with the application, reset a timer (that has an interval of say 5 minutes). If the Timer fires, then the application has been idle for 5 minutes.



来源:https://stackoverflow.com/questions/1471183/detecting-idle-time-in-net-compactframework-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!