I can't guarantee that the network user interface driver doesn't want the
screen on to show some sort of error. I wouldn't have done it that way (you
can search the source code and, if it's there, you'll probably find it;
check \public\common\oak\drivers\netui in CE5/Platform Builder first,
maybe).
Yes, suspend is a lower-power mode than idle. In idle, your code is
executing, but everything is in low-power mode. In suspend, *your code is
not executing*. If the device doesn't recover from suspend, you may have
problems in the OS configuration or the board support package code that's
supposed to bring the device out of suspend, or in the drivers, which have
to do the right thing to turn the devices back on. In particular, you can't
assume that any network connections that your application had are still
valid. Recovering from suspend is a much bigger job for the system than
just becoming non-idle and the same is true for your application. There's a
page in the Platform Builder help (and it's probably on MSDN online, too),
called something like System Power State Setting which talks a little about
the states.
You'd probably have to read the code to figure out how that event is used.
I'm not familiar with it. I'm not sure if you can still download Windows CE
5.0 evaluation edition with Platform Builder or not, but you can check at
www.microsoft.com/downloads. It's not the Windows Mobile code, of course,
but you can probably assume that most of the internals work similarly.
Ideally, your application should *stay out of the way* and let the power
manager decide when to go to sleep, only *preventing* that from happening,
never forcing it. Your application code should not need or want to know
anything about keyboard or touch or mouse events, etc. Those should be used
by the power manager to decide whether it's OK to sleep or not. That's the
usage mode that Microsoft expects. While you might be able to do what
you're doing and hack something in there, there will almost certainly be
things that you can't do because you're operating outside the box. No doubt
the next version of Windows Mobile will break what you're doing now, too.
Paul T.
"Scott Gifford" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> com> writes:
>
>> The connection to the Internet doesn't cause it. It's strictly when GWES
>> thinks that there is "user activity". I suppose that someone else might
>> fire it when something else happens, but you can't tell the difference
>> between that and any other time it fires. It's just an OS event. Treat
>> every such event the same...
>
> When I was testing this earlier and having network problems, it looked
> like every time it tried to connect to the network I saw a user
> activity event fired, even if I wasn't touching the device. Now that
> my network is working properly, I can't reproduce. Maybe it was
> weirdness in my program or my network driver.
>
> At any rate, thanks to your help I now have a simple system working to
> receive UserActivity events and put the device into idle mode if it
> doesn't receive one after the timeout specified in the registry. I'm
> calling:
>
> OpenNETCF.WindowsCE.PowerManagement.SetIdleState()
>
> to put the system into an idle state. I see that there's also:
>
> OpenNETCF.WindowsCE.PowerManagement.Suspend()
>
> but when I call that my application doesn't work reliably (the drivers
> will sometimes hang). Would it be reasonable to Suspend the system
> after it was idle for awhile, and would it save power? I don't
> entirely understand how the system normally goes from Idle mode to
> Suspend mode.
>
> Also, I'm trying to figure out how to make my application-specific
> idle timer play well with other applications that may want to keep the
> system from going idle (for example Media Player). It occurred to me
> that if the GPS driver and network driver are resetting the idle
> timer, and other applications are also resetting the idle timer, I
> could figure out if the system was idle except for my application by
> counting idle timer resets, and subtracting the ones that were
> probabaly caused by my application.
>
> To do that, I would need to be notified when the idle timer was reset.
> I found an event name that looked promising under:
>
> HKLM\System\CurrentControlSet\Control\Power\SystemIdleTimerResetEvent
>
> I tried creating an event with that name then waiting for events on
> it, but never saw any. The MSDN docs gave the impression that that
> event is "write-only". Does that sound right? Is there any other way
> to find out when applications have reset the idle timer?
>
> Otherwise, I will probably try to use a rough heuristic to guess
> whether other applications are active, such as estimating CPU usage
> while my application is idle. This isn't ideal, but it's probably
> better than draining a user's battery by never going to sleep while my
> app is running. Does anybody have suggestions for other useful
> information I could use to determine whether the device should stay
> awake?
>
> Thanks again!
>
> ---Scott.
>
>
>> "Scott Gifford" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
>>> DOT
>>> com> writes:
>>>
>>>> There is no standard way that will work for all Windows Mobile devices
>>>> ever.
>>>> On later devices, you might be able to find the name of the event used
>>>> by
>>>> GWES to signal user activity. Take a look in the registry in
>>>> HKLM/System/GWE, the value name is ActivityEvent and see if there's an
>>>> event
>>>> name there for user activity. If so, using OpenEvent with that name
>>>> should
>>>> give you a handle to that event, which you could use in a call to
>>>> WaitForSingleObject() or WaitForMultipleObjects() to detect when there
>>>> *is*
>>>> user activity and do something as a result. It works in CE5 for sure,
>>>> so
>>>> I
>>>> think that WM6 is a slam dunk. I'd guess that WM5 does it, too. Not
>>>> clear
>>>> on whether WM2003 and earlier would...
>>>
>>> Thanks, that seems to work great! I can see the event firing whenever
>>> I interact with the device, and no otherwise. It seems not to fire
>>> when I poll the GPS or send network traffic (though it does go off
>>> when I first connect to the Internet), so I can just monitor this
>>> activity and use a timer to put the device to sleep.
>>>
>>> In the handler for the activity event, is there any way to get more
>>> information about the event, for example if it was triggered by the
>>> user or by the Internet coming up?
>>>
>>> Also, does anybody have experience with the registry settings:
>>>
>>> HKEY_LOCAL_MACHINE\Comm\Cxport\NoIdleTimerReset
>>> HKEY_LOCAL_MACHINE\Comm\Tcpip\Parms\NoIdleIfAdapter
>>>
>>> They seem like they prevent the idle timer from being reset with
>>> network traffic, but they don't seem to do anything on my device. Are
>>> they NDIS-specific? Are there comparable settings for a GPRS radio?
>>>
>>> Thanks!
>>>
>>> ---Scott.