Results 1 to 5 of 5

Thread: Power Management

  1. #1

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    Power Management

    I have a routine I wrote for my Pocket PC device that can take up to 6 mins to run all the way though. (it is a complicated synchronization between the local DB and our SQL Server.) Anyway I have noticed that the handheld likes to shut itself off during the process. Is there a way that I can use the things API to temporally stop shutting down?

    Also can I detect when the device shuts down so I can make the user type their password into the app when it turns back on?

    Thanks!
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  2. #2

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    Re: Power Management

    It appears the answer to my first question is related to the API Command SystemIdleTimerReset. I will create a separate thread that just calls that function every few seconds while my sync is processing. Anyone seen any examples of using that call? I will figure it out and post.
    Last edited by Dmyze; Sep 26th, 2005 at 03:45 PM. Reason: spelling
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Power Management

    Good, please do. I have not used that, but can see the value of it.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    Re: Power Management

    First Problem down. This routine will reset its internal sleep timer. Write a little loop and your handheld will never shut down. I tested it today, wrote a little program that just displays a timer, and sat two handhelds next to each other, and had one run the program while the other just sat there doing nothing. My handheld with the program running quickly outlasted the other, and at the time of writing this post has been running for 20 mins now without shutting off. (I just needed 6 mins..)

    VB Code:
    1. Public Class CeSleep
    2.   Public Declare Sub SystemIdleTimerReset Lib "CoreDll.dll" Alias "SystemIdleTimerReset" ()
    3.  
    4.   Public Sub RestTimer()
    5.     SystemIdleTimerReset()
    6.   End Sub
    7.  
    8. End Class
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  5. #5

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    Re: Power Management

    As for the second problem, eh I'm getting lazy so I added a timer to my main form and if there is no activity from the user I'm closing the main from after 2 mins and putting the login screen back up. Not as cool as detecting the power state but just as effective.

    (I save a local variable called "LastUsed" that is a date time, then any time any of the functions in the form is called it sets LastUsed = Now, then when the timer goes off it checks if the distance between last used and now is greater then 2 mins, if so it closes the current form which causes the login screen to reappear)
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width