Hi,

i have a problem.
i do a reorganization of a database on a pocketPC (no SQL-database).
this can take some minutes (5 to 10 maybe). Unfortunately the pocketPC
will switch to Standby-mode after a few minutes - and this can cause a
corrupt database (when this happens while the application is writing
data)

Of course the user could change the settings to NOT go to standby at all
- but i cannot check this for all users, all time, anywhere.

So the question is:
is it possible to execute some code, so that the PocketPC won't go to
sleep while my function is running?

If so, how can this be done?

Thanks a lot

Boris

Re: Urgent: How to suppress Standby while working? by Chris

Chris
Thu Jun 09 13:51:53 CDT 2005

Yes. P/Invoke SystemIdleTimerReset.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Boris Nienke" <nospam@nsonic.de> wrote in message
news:1is3s4d4a5vkx$.x2yyumvjh0wy.dlg@40tude.net...
> Hi,
>
> i have a problem.
> i do a reorganization of a database on a pocketPC (no SQL-database).
> this can take some minutes (5 to 10 maybe). Unfortunately the pocketPC
> will switch to Standby-mode after a few minutes - and this can cause a
> corrupt database (when this happens while the application is writing
> data)
>
> Of course the user could change the settings to NOT go to standby at all
> - but i cannot check this for all users, all time, anywhere.
>
> So the question is:
> is it possible to execute some code, so that the PocketPC won't go to
> sleep while my function is running?
>
> If so, how can this be done?
>
> Thanks a lot
>
> Boris



Re: Urgent: How to suppress Standby while working? by Boris

Boris
Thu Jun 09 14:31:56 CDT 2005

On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:

> Yes. P/Invoke SystemIdleTimerReset.

i've found this example:
- to get the power-off time
- then i would need a timer to call SystemIdleTimerReset

Is this one correct?

[DllImport ("coredll.dll")]
private static extern int SystemParametersInfo(int uiAction , int
uiParam,
ref int pvParam, int fWinIni );
[DllImport ("coredll.dll")]
private static extern void SystemIdleTimerReset();
public SystemParamsInfo(){}

public static int GetSystemParameterTimeOutInfo()
{
int batteryIdle = 0;
int acIdle = 0;
int wakeUpIdle = 0;
int shortestIdle = 0;
SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
0);
SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
shortestIdle = batteryIdle;
shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
shortestIdle );

return shortestIdle;
}


i'm asking because i also found a posting where someone's talking about
problems with WM2003 (getting allways zero (0) from
"GetSystemParameterTimOutInfo()"

Boris

Re: Urgent: How to suppress Standby while working? by Chris

Chris
Thu Jun 09 15:58:21 CDT 2005

I wouldn't query anything. When you're doing a long operation, spawn a
worker thread that kicks the IdleReset periodically, then stop the thread
when you're done.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Boris Nienke" <nospam@nsonic.de> wrote in message
news:1ezi4rvbs5guw.1lkg5wqfatcfr.dlg@40tude.net...
> On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:
>
>> Yes. P/Invoke SystemIdleTimerReset.
>
> i've found this example:
> - to get the power-off time
> - then i would need a timer to call SystemIdleTimerReset
>
> Is this one correct?
>
> [DllImport ("coredll.dll")]
> private static extern int SystemParametersInfo(int uiAction , int
> uiParam,
> ref int pvParam, int fWinIni );
> [DllImport ("coredll.dll")]
> private static extern void SystemIdleTimerReset();
> public SystemParamsInfo(){}
>
> public static int GetSystemParameterTimeOutInfo()
> {
> int batteryIdle = 0;
> int acIdle = 0;
> int wakeUpIdle = 0;
> int shortestIdle = 0;
> SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
> 0);
> SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
> SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
> shortestIdle = batteryIdle;
> shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
> ((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
> shortestIdle );
>
> return shortestIdle;
> }
>
>
> i'm asking because i also found a posting where someone's talking about
> problems with WM2003 (getting allways zero (0) from
> "GetSystemParameterTimOutInfo()"
>
> Boris



Re: Urgent: How to suppress Standby while working? by Paul

Paul
Thu Jun 09 16:04:33 CDT 2005

You could set the sleep time in the thread to the idle timeout, if you
wanted to use as few cycles as reasonable for the thread itself...

Paul T.

"Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
news:%231Un5XTbFHA.2124@TK2MSFTNGP14.phx.gbl...
>I wouldn't query anything. When you're doing a long operation, spawn a
>worker thread that kicks the IdleReset periodically, then stop the thread
>when you're done.
>
> --
> Chris Tacke
> Co-founder
> OpenNETCF.org
> Are you using the SDF? Let's do a case study.
> Email us at d c s @ o p e n n e t c f . c o m
> http://www.opennetcf.org/donate
>
>
> "Boris Nienke" <nospam@nsonic.de> wrote in message
> news:1ezi4rvbs5guw.1lkg5wqfatcfr.dlg@40tude.net...
>> On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:
>>
>>> Yes. P/Invoke SystemIdleTimerReset.
>>
>> i've found this example:
>> - to get the power-off time
>> - then i would need a timer to call SystemIdleTimerReset
>>
>> Is this one correct?
>>
>> [DllImport ("coredll.dll")]
>> private static extern int SystemParametersInfo(int uiAction , int
>> uiParam,
>> ref int pvParam, int fWinIni );
>> [DllImport ("coredll.dll")]
>> private static extern void SystemIdleTimerReset();
>> public SystemParamsInfo(){}
>>
>> public static int GetSystemParameterTimeOutInfo()
>> {
>> int batteryIdle = 0;
>> int acIdle = 0;
>> int wakeUpIdle = 0;
>> int shortestIdle = 0;
>> SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
>> 0);
>> SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
>> SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
>> shortestIdle = batteryIdle;
>> shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
>> ((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
>> shortestIdle );
>>
>> return shortestIdle;
>> }
>>
>>
>> i'm asking because i also found a posting where someone's talking about
>> problems with WM2003 (getting allways zero (0) from
>> "GetSystemParameterTimOutInfo()"
>>
>> Boris
>
>



Re: Urgent: How to suppress Standby while working? by Boris

Boris
Fri Jun 10 01:03:49 CDT 2005

ah, OK i see - so using the idle-timout is just a "cleaner" solution to
reduce the timer-event-calls.

But it will work when i simply set the timer to 30 seconds or something?

I will try when i'm back home - thanks!

Boris

On Thu, 9 Jun 2005 14:04:33 -0700, Paul G. Tobey [eMVP] wrote:

> You could set the sleep time in the thread to the idle timeout, if you
> wanted to use as few cycles as reasonable for the thread itself...
>
> Paul T.
>
> "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
> news:%231Un5XTbFHA.2124@TK2MSFTNGP14.phx.gbl...
>>I wouldn't query anything. When you're doing a long operation, spawn a
>>worker thread that kicks the IdleReset periodically, then stop the thread
>>when you're done.
>>
>> --
>> Chris Tacke
>> Co-founder
>> OpenNETCF.org
>> Are you using the SDF? Let's do a case study.
>> Email us at d c s @ o p e n n e t c f . c o m
>> http://www.opennetcf.org/donate
>>
>>
>> "Boris Nienke" <nospam@nsonic.de> wrote in message
>> news:1ezi4rvbs5guw.1lkg5wqfatcfr.dlg@40tude.net...
>>> On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:
>>>
>>>> Yes. P/Invoke SystemIdleTimerReset.
>>>
>>> i've found this example:
>>> - to get the power-off time
>>> - then i would need a timer to call SystemIdleTimerReset
>>>
>>> Is this one correct?
>>>
>>> [DllImport ("coredll.dll")]
>>> private static extern int SystemParametersInfo(int uiAction , int
>>> uiParam,
>>> ref int pvParam, int fWinIni );
>>> [DllImport ("coredll.dll")]
>>> private static extern void SystemIdleTimerReset();
>>> public SystemParamsInfo(){}
>>>
>>> public static int GetSystemParameterTimeOutInfo()
>>> {
>>> int batteryIdle = 0;
>>> int acIdle = 0;
>>> int wakeUpIdle = 0;
>>> int shortestIdle = 0;
>>> SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
>>> 0);
>>> SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
>>> SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
>>> shortestIdle = batteryIdle;
>>> shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
>>> ((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
>>> shortestIdle );
>>>
>>> return shortestIdle;
>>> }
>>>
>>>
>>> i'm asking because i also found a posting where someone's talking about
>>> problems with WM2003 (getting allways zero (0) from
>>> "GetSystemParameterTimOutInfo()"
>>>
>>> Boris
>>
>>

Re: Urgent: How to suppress Standby while working? by Paul

Paul
Fri Jun 10 10:43:02 CDT 2005

That depends. You can configure the device to go to sleep pretty darn fast.
As long as the time-out is longer than the period on which you are repeating
your calls, yes, it should work.

Paul T.

"Boris Nienke" <nospam@nsonic.de> wrote in message
news:o7ew0db8c5o0$.1bhazb8ts5tds$.dlg@40tude.net...
> ah, OK i see - so using the idle-timout is just a "cleaner" solution to
> reduce the timer-event-calls.
>
> But it will work when i simply set the timer to 30 seconds or something?
>
> I will try when i'm back home - thanks!
>
> Boris
>
> On Thu, 9 Jun 2005 14:04:33 -0700, Paul G. Tobey [eMVP] wrote:
>
>> You could set the sleep time in the thread to the idle timeout, if you
>> wanted to use as few cycles as reasonable for the thread itself...
>>
>> Paul T.
>>
>> "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
>> news:%231Un5XTbFHA.2124@TK2MSFTNGP14.phx.gbl...
>>>I wouldn't query anything. When you're doing a long operation, spawn a
>>>worker thread that kicks the IdleReset periodically, then stop the thread
>>>when you're done.
>>>
>>> --
>>> Chris Tacke
>>> Co-founder
>>> OpenNETCF.org
>>> Are you using the SDF? Let's do a case study.
>>> Email us at d c s @ o p e n n e t c f . c o m
>>> http://www.opennetcf.org/donate
>>>
>>>
>>> "Boris Nienke" <nospam@nsonic.de> wrote in message
>>> news:1ezi4rvbs5guw.1lkg5wqfatcfr.dlg@40tude.net...
>>>> On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:
>>>>
>>>>> Yes. P/Invoke SystemIdleTimerReset.
>>>>
>>>> i've found this example:
>>>> - to get the power-off time
>>>> - then i would need a timer to call SystemIdleTimerReset
>>>>
>>>> Is this one correct?
>>>>
>>>> [DllImport ("coredll.dll")]
>>>> private static extern int SystemParametersInfo(int uiAction , int
>>>> uiParam,
>>>> ref int pvParam, int fWinIni );
>>>> [DllImport ("coredll.dll")]
>>>> private static extern void SystemIdleTimerReset();
>>>> public SystemParamsInfo(){}
>>>>
>>>> public static int GetSystemParameterTimeOutInfo()
>>>> {
>>>> int batteryIdle = 0;
>>>> int acIdle = 0;
>>>> int wakeUpIdle = 0;
>>>> int shortestIdle = 0;
>>>> SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
>>>> 0);
>>>> SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
>>>> SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
>>>> shortestIdle = batteryIdle;
>>>> shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
>>>> ((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
>>>> shortestIdle );
>>>>
>>>> return shortestIdle;
>>>> }
>>>>
>>>>
>>>> i'm asking because i also found a posting where someone's talking about
>>>> problems with WM2003 (getting allways zero (0) from
>>>> "GetSystemParameterTimOutInfo()"
>>>>
>>>> Boris
>>>
>>>



Re: Urgent: How to suppress Standby while working? by Boris

Boris
Mon Jun 13 01:22:14 CDT 2005

The shortest time i can set on my device is 1 minute. It seems to be the
same on other devices too.

Now i've set a timer to 30 seconds to call the reset - it works!

Thanks A LOT! That saved my day!

Boris

On Fri, 10 Jun 2005 08:43:02 -0700, Paul G. Tobey [eMVP] wrote:

> That depends. You can configure the device to go to sleep pretty darn fast.
> As long as the time-out is longer than the period on which you are repeating
> your calls, yes, it should work.
>
> Paul T.
>
> "Boris Nienke" <nospam@nsonic.de> wrote in message
> news:o7ew0db8c5o0$.1bhazb8ts5tds$.dlg@40tude.net...
>> ah, OK i see - so using the idle-timout is just a "cleaner" solution to
>> reduce the timer-event-calls.
>>
>> But it will work when i simply set the timer to 30 seconds or something?
>>
>> I will try when i'm back home - thanks!
>>
>> Boris
>>
>> On Thu, 9 Jun 2005 14:04:33 -0700, Paul G. Tobey [eMVP] wrote:
>>
>>> You could set the sleep time in the thread to the idle timeout, if you
>>> wanted to use as few cycles as reasonable for the thread itself...
>>>
>>> Paul T.
>>>
>>> "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
>>> news:%231Un5XTbFHA.2124@TK2MSFTNGP14.phx.gbl...
>>>>I wouldn't query anything. When you're doing a long operation, spawn a
>>>>worker thread that kicks the IdleReset periodically, then stop the thread
>>>>when you're done.
>>>>
>>>> --
>>>> Chris Tacke
>>>> Co-founder
>>>> OpenNETCF.org
>>>> Are you using the SDF? Let's do a case study.
>>>> Email us at d c s @ o p e n n e t c f . c o m
>>>> http://www.opennetcf.org/donate
>>>>
>>>>
>>>> "Boris Nienke" <nospam@nsonic.de> wrote in message
>>>> news:1ezi4rvbs5guw.1lkg5wqfatcfr.dlg@40tude.net...
>>>>> On Thu, 9 Jun 2005 14:51:53 -0400, Chris Tacke, eMVP wrote:
>>>>>
>>>>>> Yes. P/Invoke SystemIdleTimerReset.
>>>>>
>>>>> i've found this example:
>>>>> - to get the power-off time
>>>>> - then i would need a timer to call SystemIdleTimerReset
>>>>>
>>>>> Is this one correct?
>>>>>
>>>>> [DllImport ("coredll.dll")]
>>>>> private static extern int SystemParametersInfo(int uiAction , int
>>>>> uiParam,
>>>>> ref int pvParam, int fWinIni );
>>>>> [DllImport ("coredll.dll")]
>>>>> private static extern void SystemIdleTimerReset();
>>>>> public SystemParamsInfo(){}
>>>>>
>>>>> public static int GetSystemParameterTimeOutInfo()
>>>>> {
>>>>> int batteryIdle = 0;
>>>>> int acIdle = 0;
>>>>> int wakeUpIdle = 0;
>>>>> int shortestIdle = 0;
>>>>> SystemParametersInfo( SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdle,
>>>>> 0);
>>>>> SystemParametersInfo( SPI_GETEXTERNALIDLETIMEOUT, 0, ref acIdle, 0);
>>>>> SystemParametersInfo( SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeUpIdle, 0);
>>>>> shortestIdle = batteryIdle;
>>>>> shortestIdle = ((acIdle > 0) && (acIdle < shortestIdle) ? acIdle :
>>>>> ((wakeUpIdle > 0) && (wakeUpIdle < shortestIdle)) ? wakeUpIdle :
>>>>> shortestIdle );
>>>>>
>>>>> return shortestIdle;
>>>>> }
>>>>>
>>>>>
>>>>> i'm asking because i also found a posting where someone's talking about
>>>>> problems with WM2003 (getting allways zero (0) from
>>>>> "GetSystemParameterTimOutInfo()"
>>>>>
>>>>> Boris
>>>>
>>>>