PC Review


Reply
Thread Tools Rate Thread

Urgent: How to suppress Standby while working?

 
 
Boris Nienke
Guest
Posts: n/a
 
      9th Jun 2005
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
 
Reply With Quote
 
 
 
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      9th Jun 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" <(E-Mail Removed)> wrote in message
news:1is3s4d4a5vkx$.(E-Mail Removed)...
> 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



 
Reply With Quote
 
Boris Nienke
Guest
Posts: n/a
 
      9th Jun 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
 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      9th Jun 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      9th Jun 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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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

>
>



 
Reply With Quote
 
Boris Nienke
Guest
Posts: n/a
 
      10th Jun 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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

>>
>>

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      10th Jun 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" <(E-Mail Removed)> wrote in message
news7ew0db8c5o0$.1bhazb8ts5tds$.(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>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" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> 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
>>>
>>>



 
Reply With Quote
 
Boris Nienke
Guest
Posts: n/a
 
      13th Jun 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" <(E-Mail Removed)> wrote in message
> news7ew0db8c5o0$.1bhazb8ts5tds$.(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>>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" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> 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
>>>>
>>>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standby not working antioch Windows XP General 6 28th Nov 2006 02:07 AM
Outlook Calendar suppress non working days in multiday view =?Utf-8?B?Q29uc3VsdGluZ0pheQ==?= Microsoft Outlook Calendar 0 18th Nov 2005 05:27 PM
W2K SP4 - Standby not working =?Utf-8?B?ZHJpYw==?= Microsoft Windows 2000 0 8th Aug 2005 12:26 PM
Standby not working Amy Windows XP General 2 26th May 2004 05:41 AM
URGENT - Pivot Table Not Working - URGENT Behrak Shahriari Microsoft Access Forms 1 12th Sep 2003 05:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:24 PM.