[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

.net Compact Framework: Timer is stopping when device goes into standby mode negating auto logout functionality

Posted on 2007-11-28
5
Medium Priority
?
3,814 Views
Last Modified: 2013-12-21
I'm developing an application in .net compact framework 2.0 (VB.net) for pocket pc's and one of the features that I implemented is an autologout timer.

If the user is inactive for a specified amount of time (specified by the user) the login screen will come up forcing them to log back in before proceeding. This works quite well in most situations, however, if the device goes into stand by the timer seems to stop. It will start up again when the user comes out of stand by mode, but it defeats the purpose. Basically if the device has a lower standby timeout time than the specified auto logout value, the user never gets logged out.

Thus far the only solutions I've been able to come up with are:

1. I can set the standby mode timeout from the code. So that it is 1 second greater than the autologout time (and set it back to whatever it was before if class closes)
2. Try to handle the "Into standby mode" and "Out of stand by mode" events and compare the system times between those 2 events and see if it has <-- I'm not sure if it's possible to handle these events and will require more investigation.
3. Figure out a way to have the timer run and bring up the login screen regardless of stand by mode.

I would prefer number 3 but I would accept 2 as well, but I'm not sure how to handle the events. After talking to my product people, 1 is not an option.
0
Comment
Question by:BlahMatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 750 total points
ID: 20367989
0
 

Author Comment

by:BlahMatt
ID: 20368360
I'll give that a shot

public enum PowerMode
{
ReevaluateStat = 0x0001,
PowerChange = 0x0002,
UnattendedMode = 0x0003,
SuspendKeyOrPwrButtonPressed = 0x0004,
SuspendKeyReleased = 0x0005,
AppButtonPressed = 0x0006
}

[DllImport("CoreDll.dll")]
public static extern void PowerPolicyNotify(PowerMode powermode, int flags);

On start of app:
PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 1);

On end of app:
PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 0);


Unfortunately one of our support people just came and took my device... I'll update later how it turns out.

Thanks Mikal
0
 
LVL 3

Assisted Solution

by:wizrr
wizrr earned 750 total points
ID: 20369901
Maybe you must implement your own timer. Try to use pinvoke to CreateTimer os something. Maybe you should use an separated thread with Sleep and event raising. Like this:
//that must be ISynchronizeInvoke, but .NET CF does not have it
Control controlSync = ...// your form
Thread thread = new Thread(new ParameterizedThreadStart(ThreadStart));
AutoResetEvent eventStart = new AutoResetEvent();
TimerCommand command = TimerCommand.Start;
thread.Start(controlSync);
int timerPeriod = 1000; // every second
TimerEvent doOnTimer = OnTimer;
//
...
public enum TimerCommand {
  Start,
  End
}
public delegate void TimerEvent();
...
//
private ThreadStart(Object syncObj) {
   Control controlSync = (Control)syncObj;
   while ( true ) {
      eventStart.WaitOne()
      if (command == Start) {
        while (command == Start) {
           if (eventStart.WaitOne(timerPeriod, false)) {
              // raise event
              // maybe timer does not work because it trying to sync invoke
              // with your app form
              // but application is sleepin (message loop suspended or something i dont know)
              controlSync.BeginInvoke(doOnTimer);
           } else {
             if (command == End) {
                return;
             }
           }
        }
      } else {
        return;
      }
   }
}

Open in new window

0
 

Author Comment

by:BlahMatt
ID: 20400100
Sorry it's taken me so long to respond. I tried both of those solutions and neither seems to work. I wrote a sample app that updates a text box on the timer fire event and implemented both solutions. The text box wouldn't update until I brought the ppc out of sleep mode.
0
 

Author Comment

by:BlahMatt
ID: 20451930
We ended up closing this as a known issue and telling users to set their auto logout value to less than the stand by value.

Thanks for everyones help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question