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?
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 )
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/
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 aSystem.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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.