Urgent: How to suppress Standby while working?

  • Thread starter Thread starter Boris Nienke
  • Start date Start date
B

Boris Nienke

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
 
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
 
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 said:
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
 
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 said:
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 said:
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
 
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

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 said:
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 said:
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
 
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 said:
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

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 said:
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


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
 
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

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 said:
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

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.

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


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
 
Back
Top