PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

workaround for GetIdleTime?

Im trying to write a simple service dll that will launch an app of choice after a certain amount of idle time passes.

According to MSDN, there is a function called GetIdleTime (not found in sdk headers though, had to do a GetProcAddress from coredll to get it) and apparently is not supported on my device (always returns -1)

So, is there another way to check how long the device has been idle? Im finding it very difficult to find any information on how to query for idle time on pocket pc...surely there has to be some way?
BrandonBlais · 12 Mar 2007, 14:48 UTC — RE: getIdleTime workaround
I had the same problem...I tried various sollutions on the web but wasn't able to get any to work...

here is my work around....
Code:

public class PowerNotifications
{
Thread t = null;
bool done = false;

public PowerNotifications()
{
t = new Thread(new ThreadStart(DoWork));
}

public void Start()
{
t.Start();
}

public void Stop()
{
done = true;
}

private static DateTime last = DateTime.Now;
private static DateTime current = DateTime.Now;

private void DoWork()
{
while(!done)
{
DateTime d = DateTime.Now;
last = current;
current = d;

long seconds = (current.Ticks - last.Ticks) / System.TimeSpan.TicksPerSecond;
if (seconds > 5)
{
Console.WriteLine("More then 5 seconds idle");
}
Thread.Sleep(500);
}
}

}