|
-
Sep 23rd, 2005, 06:27 PM
#1
Thread Starter
Addicted Member
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
-
Sep 26th, 2005, 03:43 PM
#2
Thread Starter
Addicted Member
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
-
Sep 26th, 2005, 07:09 PM
#3
Re: Power Management
Good, please do. I have not used that, but can see the value of it.
My usual boring signature: Nothing
 
-
Sep 26th, 2005, 07:45 PM
#4
Thread Starter
Addicted Member
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:
Public Class CeSleep
Public Declare Sub SystemIdleTimerReset Lib "CoreDll.dll" Alias "SystemIdleTimerReset" ()
Public Sub RestTimer()
SystemIdleTimerReset()
End Sub
End Class
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
-
Sep 27th, 2005, 02:50 AM
#5
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|