[英]Detecting idle time in .NET CompactFramework Applications
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. 如果用户没有与自定义构建的设备上运行的紧凑型框架应用程序交互2分钟,我们希望激活一个过程。
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. 我找到了代码项目( http://www.codeproject.com/KB/cs/ApplicationIdle.aspx )的出色C#示例代码,但紧凑型框架不支持该代码,因为此代码取决于Timers类和Application.Idle事件。
Can someone suggest me how to detect idle time? 有人可以建议我如何检测空闲时间吗?
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 ) (存档版本: http ://web.archive.org/web/20090615073146/http: //blog.opennetcf.com/ctacke/2009/05/19/DetectingApplicationIdle.aspx )
I haven't used the .NET Compact Framework in nearly 4 years, but maybe this is something that you could P/Invoke? 我已经有近四年没有使用.NET Compact Framework了,但是也许您可以P / Invoke? Or maybe OpenNetCF have something for this in their library?
也许OpenNetCF在其库中为此提供了一些东西? (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/
(过去,这为我节省了很多时间。)我在那儿做了一次快速搜索,他们确实有一个Timers类,您可能想检查一下是否有帮助: http:// www.opennetcf.com/library/sdf/
Differences Between the .NET Compact Framework and the .NET Framework : .NET Compact Framework和.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 aSystem.Windows.Forms.Timer
object to true or false.计时器不支持
System.Timers.Timer
对象的Start和Stop方法,但是可以通过将System.Windows.Forms.Timer
对象的Enabled属性设置为true或false来启动和停止计时。
You can also use System.Threading.Timer
您也可以使用
System.Threading.Timer
Supported in: 3.5, 2.0, 1.0 .NET Compact Framework 受以下版本支持: 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). 您可以使用计时器来检测空闲活动,如下所示:每次用户与应用程序进行交互时,请重置计时器(间隔为5分钟)。 If the Timer fires, then the application has been idle for 5 minutes.
如果计时器触发,则应用程序已空闲5分钟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.