0

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?

Gopinath
  • 1,858
  • 7
  • 31
  • 50

3 Answers3

4

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)

ChrisB
  • 2,497
  • 2
  • 24
  • 43
ctacke
  • 66,480
  • 18
  • 94
  • 155
  • Not able to use this APIs on Windows XP box:http://stackoverflow.com/questions/1471794/unable-to-load-dll-coredll-dll-the-specified-module-could-not-be-found-on-wi – Gopinath Sep 24 '09 at 13:48
1

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/

MetalMikester
  • 1,067
  • 1
  • 13
  • 15
0

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.

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • But there is no support for System.Windows.Forms.Application.Idle event in compact framework. That's where I'm struck now. – Gopinath Sep 24 '09 at 11:56
  • 1
    So he should put a timer reset in the Click for every Form and Control in the app? Seriously? How would that ever be maintainable? – ctacke Sep 24 '09 at 12:49
  • Hi Chris: that's not what I was suggesting. I done it before, by creating a base form containing the idle logic, and then inheriting from it. – Mitch Wheat Sep 24 '09 at 13:24
  • ...which seems equivalent to the example you linked to. – Mitch Wheat Sep 24 '09 at 13:25