all groups > dotnet compact framework > july 2005 >
You're in the

dotnet compact framework

group:

prevent idle or sleep mode



prevent idle or sleep mode William
7/29/2005 12:15:02 PM
dotnet compact framework: Greetings,
I am using a ce.net device with vb.net. I am trying to prevent the device
from going into a power save mode while my app is running. I have tried
SystemIdleTimerReset call , but it seems to have no effect. Can anyone help
me out here?
regards,
Re: prevent idle or sleep mode Paul G. Tobey [eMVP]
7/29/2005 12:40:41 PM
It does work, unless the device is going into some type of critical shut
down. What does your declaration for it look like? What device,
specifically, is it?

Paul T.

[quoted text, click to view]

Re: prevent idle or sleep mode William
8/1/2005 4:41:01 AM
Paul,
Thank you for your response.
Here is my declaration:
<DllImport("coredll.dll")> Private Sub SystemIdleTimerReset()
End Sub

The unit I am using is a DAP Technologies CE5320LS running CE.NET V 4.20

William
[quoted text, click to view]
Re: prevent idle or sleep mode Paul G. Tobey [eMVP]
8/1/2005 8:50:55 AM
I don't see anything wrong with that and I'm surprised it doesn't work. I'd
contact the device vendor and ask them how to accomplish what you want to do
on their device.

How often are you calling SystemIdleTimerReset() when the application is
running?

Paul T.

[quoted text, click to view]

Re: prevent idle or sleep mode William
8/1/2005 10:21:07 AM
Thanks again for the response.
I am calling the reset every 2 minutes. The unit sleeps after 3 minutes.
William

[quoted text, click to view]
seems like it does not work cppdeveloper
8/10/2005 1:11:03 PM
According to Microsoft document:
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/guide_ppc/html/ppc_programming_pocket_pc_2002_lfyy.asp)

===========================================
You can override the automatic suspend that occurs when no user input has
occurred for a period of time. To prevent automatic power down, call the
Windows CE SystemParametersInfo function for each of the three time-out
values, SPI_GETBATTERYIDLETIMEOUT, SPI_GETEXTERNALIDLETIMEOUT, and
SPI_GETWAKEUPIDLETIMEOUT, as shown in the following code. Your application
must call the SystemIdleTimerReset function more frequently than any of the
nonzero time-out values.

DWORD batIdle, acIdle, wakeUpIdle, shortestIdle;
TCHAR szOutput[200];

// Get the values.
SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT,0,&batIdle,0);
SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT,0,&acIdle,0);
SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT,0,&wakeUpIdle,0);

// Determine which is the lowest nonzero value.
shortestIdle=batIdle;
shortestIdle=((acIdle>0)&&(acIdle<shortestIdle)) ? acIdle :
(((wakeUpIdle>0)&&(wakeUpIdle<shortestIdle)) ? wakeUpIdle : shortestIdle);

if (shortestIdle==0)
// If all values are zero, the device can never time out.
wsprintf(szOutput,_T("Battery Idle Timeout: %d\nAC Power Idle Timeout:
%d\nWakeup Idle Timeout: %d\nThe device will not time out."),batIdle, acIdle,
wakeUpIdle);
else
{
// Otherwise, you need to reset the idle timer more
// frequently than the lowest time-out value.
wsprintf(szOutput,_T("Battery Idle Timeout: %d\nAC Power
Idle Timeout: %d\nWakeup Idle Timeout: %d\nYou need to
call SystemIdleTimerReset at least every %d
sec"),batIdle, acIdle, wakeUpIdle, shortestIdle-1);
}
MessageBox(hWnd,szOutput,_T("Results"),MB_OK);
===========================================

I try to following the instruction in the document on a HHP Dolphin 9500,
seems like it does not work. Though batIdle, acIdle, wakeUpIdle are all 0,
AddThis Social Bookmark Button