SystemIdleTimerReset doesn't work

G

Gianco

Hello

I would avoid the automatic suspend of my PDA in some conditions. I
call the SystemIdleTimerReset function each 5 seconds since this
conditions are true but my PDA goes however in suspend mode after 5
minutes (the suspend time I selected). Is it possible that there's any
registry voice that disable the functionality of SystemIdleTimerReset?

Thanks in advance
Gianco
 
P

Paul G. Tobey [eMVP]

I've never seen that. Are you really sure you *are* calling it? I'm
guessing that you probably are not. What battery state is the device in?
What are the time-outs for all situations set to?

Paul T.
 
G

Gianco

Hello

Yes I'm sure I call this function (each time I call this function in a
timer I increment a value in a label). The settings in the Control
Panel are

Power Properties:

Power scheme ---> AC Power and Battery Power, they have the same
settings

Switch state to User Idle ---> Never (the combo is disabled)
Switch state to System Idle ---> Never (the combo is disabled)
Switch state to Suspend ---> After 5 minutes

What seems strange to me is that the System Idle combo is disabled,
maybe this timer should be set instead of the 'suspend' one, since the
name of the function I would use is SystemIdleTimerReset. Maybe my PDA
doesn't support the System Idle timer?!?! Unfortunately I haven't a
good assistance from our PDA supplier

I tried also to fire keyboard and mouse events calling the keybd_event
and mouse_event functions, and even if I change the mouse position...
nothing to do, the device goes in suspend mode

Is there any other trick to avoid the suspend?
 
P

Paul G. Tobey [eMVP]

What device is it? It sounds like they are not clearing the counter
themselves when user events occur. If that's the case, it seems like your
only choice is to turn off suspending at all (other than by user command).

Paul T.
 
G

Gianco

Hello

I'm trying another solution. I written the following function to
enable/disable the automatic suspend, the suspend is disabled while
the application is doing some measuring

public static void SetSuspendTimeout(int iSecondsTimeout)
{
RegistryKey Key;

Key = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(
"\\System\\CurrentControlSet\\Control\\Power\\Timeouts");

Key.SetValue("ACSuspend", iSecondsTimeout);
Key.SetValue("BattSuspend", iSecondsTimeout);

Key.Close();

// Now I would tell to OS to reload the activity timeout
// but it doesn't work. They are applied, of course
// only after a soft reset
FireEvent("PowerManager/ReloadActivityTimeouts");
}

FireEvent is a function written in C++ and it returns me a TRUE value

extern "C" __declspec(dllexport) BOOL FireEvent(TCHAR *sEventName)
{
HANDLE hEvent;
BOOL bResult;

hEvent = CreateEvent(NULL, FALSE, TRUE, sEventName);

if (hEvent == INVALID_HANDLE_VALUE) return(FALSE);

bResult = SetEvent(hEvent);

CloseHandle(hEvent);

return(bResult);
}

Is it correct what I'm doing?

Gianco
 
G

Guest

Fisrt, why create a DLL to call SetEvent? I mean if you're going to
P/Invoke, why not P/Invoke EventModify directly?
Second, I'd just broadcast a WM_SETTINGCHANGE after modifying the reg keys.

-Chris

Gianco said:
Hello

I'm trying another solution. I written the following function to
enable/disable the automatic suspend, the suspend is disabled while
the application is doing some measuring

public static void SetSuspendTimeout(int iSecondsTimeout)
{
RegistryKey Key;

Key = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(
"\\System\\CurrentControlSet\\Control\\Power\\Timeouts");

Key.SetValue("ACSuspend", iSecondsTimeout);
Key.SetValue("BattSuspend", iSecondsTimeout);

Key.Close();

// Now I would tell to OS to reload the activity timeout
// but it doesn't work. They are applied, of course
// only after a soft reset
FireEvent("PowerManager/ReloadActivityTimeouts");
}

FireEvent is a function written in C++ and it returns me a TRUE value

extern "C" __declspec(dllexport) BOOL FireEvent(TCHAR *sEventName)
{
HANDLE hEvent;
BOOL bResult;

hEvent = CreateEvent(NULL, FALSE, TRUE, sEventName);

if (hEvent == INVALID_HANDLE_VALUE) return(FALSE);

bResult = SetEvent(hEvent);

CloseHandle(hEvent);

return(bResult);
}

Is it correct what I'm doing?

Gianco

Paul G. Tobey said:
What device is it? It sounds like they are not clearing the counter
themselves when user events occur. If that's the case, it seems like
your
only choice is to turn off suspending at all (other than by user
command).

Paul T.


Gianco said:
Hello

Yes I'm sure I call this function (each time I call this function in a
timer I increment a value in a label). The settings in the Control
Panel are

Power Properties:

Power scheme ---> AC Power and Battery Power, they have the same
settings

Switch state to User Idle ---> Never (the combo is disabled)
Switch state to System Idle ---> Never (the combo is disabled)
Switch state to Suspend ---> After 5 minutes

What seems strange to me is that the System Idle combo is disabled,
maybe this timer should be set instead of the 'suspend' one, since the
name of the function I would use is SystemIdleTimerReset. Maybe my PDA
doesn't support the System Idle timer?!?! Unfortunately I haven't a
good assistance from our PDA supplier

I tried also to fire keyboard and mouse events calling the keybd_event
and mouse_event functions, and even if I change the mouse position...
nothing to do, the device goes in suspend mode

Is there any other trick to avoid the suspend?

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
wrote in message I've never seen that. Are you really sure you *are* calling it? I'm
guessing that you probably are not. What battery state is the device
in?
What are the time-outs for all situations set to?

Paul T.

Hello

I would avoid the automatic suspend of my PDA in some conditions. I
call the SystemIdleTimerReset function each 5 seconds since this
conditions are true but my PDA goes however in suspend mode after 5
minutes (the suspend time I selected). Is it possible that there's
any
registry voice that disable the functionality of
SystemIdleTimerReset?

Thanks in advance
Gianco
 
G

Gianco

Hello Chris

I haven't created a DLL only for this function, I use it also for
other stuffs. Of course is possible to P/Invoke everything but often
is faster to write code that must call OS functions in C since is not
necessary to define many prototypes and constant values (power of
include files...)

Ok, I'll try to broadcast this message. Thank you very much for the
help!

Gianco

Fisrt, why create a DLL to call SetEvent? I mean if you're going to
P/Invoke, why not P/Invoke EventModify directly?
Second, I'd just broadcast a WM_SETTINGCHANGE after modifying the reg keys.

-Chris

Gianco said:
Hello

I'm trying another solution. I written the following function to
enable/disable the automatic suspend, the suspend is disabled while
the application is doing some measuring

public static void SetSuspendTimeout(int iSecondsTimeout)
{
RegistryKey Key;

Key = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(
"\\System\\CurrentControlSet\\Control\\Power\\Timeouts");

Key.SetValue("ACSuspend", iSecondsTimeout);
Key.SetValue("BattSuspend", iSecondsTimeout);

Key.Close();

// Now I would tell to OS to reload the activity timeout
// but it doesn't work. They are applied, of course
// only after a soft reset
FireEvent("PowerManager/ReloadActivityTimeouts");
}

FireEvent is a function written in C++ and it returns me a TRUE value

extern "C" __declspec(dllexport) BOOL FireEvent(TCHAR *sEventName)
{
HANDLE hEvent;
BOOL bResult;

hEvent = CreateEvent(NULL, FALSE, TRUE, sEventName);

if (hEvent == INVALID_HANDLE_VALUE) return(FALSE);

bResult = SetEvent(hEvent);

CloseHandle(hEvent);

return(bResult);
}

Is it correct what I'm doing?

Gianco

Paul G. Tobey said:
What device is it? It sounds like they are not clearing the counter
themselves when user events occur. If that's the case, it seems like
your
only choice is to turn off suspending at all (other than by user
command).

Paul T.


Hello

Yes I'm sure I call this function (each time I call this function in a
timer I increment a value in a label). The settings in the Control
Panel are

Power Properties:

Power scheme ---> AC Power and Battery Power, they have the same
settings

Switch state to User Idle ---> Never (the combo is disabled)
Switch state to System Idle ---> Never (the combo is disabled)
Switch state to Suspend ---> After 5 minutes

What seems strange to me is that the System Idle combo is disabled,
maybe this timer should be set instead of the 'suspend' one, since the
name of the function I would use is SystemIdleTimerReset. Maybe my PDA
doesn't support the System Idle timer?!?! Unfortunately I haven't a
good assistance from our PDA supplier

I tried also to fire keyboard and mouse events calling the keybd_event
and mouse_event functions, and even if I change the mouse position...
nothing to do, the device goes in suspend mode

Is there any other trick to avoid the suspend?

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
wrote in message I've never seen that. Are you really sure you *are* calling it? I'm
guessing that you probably are not. What battery state is the device
in?
What are the time-outs for all situations set to?

Paul T.

Hello

I would avoid the automatic suspend of my PDA in some conditions. I
call the SystemIdleTimerReset function each 5 seconds since this
conditions are true but my PDA goes however in suspend mode after 5
minutes (the suspend time I selected). Is it possible that there's
any
registry voice that disable the functionality of
SystemIdleTimerReset?

Thanks in advance
Gianco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top