在PocketPC上运行后台服务 [英] Running background services on a PocketPC

查看:145
本文介绍了在PocketPC上运行后台服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近给自己买了一台新手机,运行Windows Mobile 6.1 Professional。当然,我目前正在研究做一些编码,在爱好的基础上。我的计划是有一个服务作为DLL运行,由Services.exe加载。这需要收集som数据,并做定期处理(每5-10分钟)。



由于我需要定期运行,这对我来说有点问题,系统通常会在短时间内进入休眠状态



我一直在阅读MSDN上的所有文档,以及MSDN博客关于这个主题,在我看来,有三个可能的解决方案:


  1. 通过调用 SystemIdleTimerReset


  2. 让系统通过 CeRunAppAtTime 定期唤醒,然后进入


  3. 使用无人参与状态,而不是进入完全暂停状态。


第二种方法似乎是然而,优选地,这将需要系统在唤醒时调用可执行体,其中唯一的任务是通知我的服务它应该开始处理。这似乎有点不必要,我想避免这个额外的可执行文件。我当然可以把我的所有处理这个额外的可执行文件,但我想使用一些运行时提供的设施作为服务,也没有程序弹出(即使它在后台)每当处理开始。



乍一看,第三种方法似乎与第一种方法有相同的基本问题。但是,我已经阅读了一些MSDN博客,这可能是实际节省电池消耗与这种方法,而不是经常进入和退出暂停模式(这是的论点是,WM平台的性质是当系统处于空闲状态时,电池消耗很少,而进入和退出暂停需要相当多的处理)。



所以我想我的问题如下:




  • 在我的情况下,你会推荐哪种方法?


  • 在第二种方法的情况下,可以消除对电池消耗的需要,通知可执行文件?通过替代API函数或平台上的现有通用应用程序?


  • 在第三种方法的情况下,该权利要求,当使用无人值守模式进入暂停时可以延长电池寿命。例如。


  • 实施特定(奖金)问题:是否有必要将系统从暂停状态定期调用 SystemIdleTimerReset 以保持无人参与模式?






请包含在您的帐户中回应你是否基于你的回应知识,或只是猜测(后者也非常欢迎!)。



如果您认为我需要澄清此问题的任何部分,请发表评论。

方案

CERunAppAtTime是一个误解很多的API(主要是因为可怕的名字)。 不必运行应用程序。它可以简单地设置一个命名的系统事件(请参阅MSDN文档中的pwszAppName参数的说明) )。如果你想知道它什么时候被触发(当你的应用程序把设备重新睡眠,当它完成处理),只需要一个工作线程在同一个命名的事件上做一个WaitForSingleObject。



无人值守状态通常用于需要保持应用程序连续运行(如MP3播放器)但通过关闭背光(可能是最耗电的子系统)节省电量的设备。



很明显,无人值守模式使用的电量比暂停多,因为暂停只有RAM自刷新的电量消耗。在无人值守模式下,处理器是stuill供电和运行(和几个外设可能太取决于OEM如何定义他们的无人值守模式)。



SystemIdleTimerReset只是阻止电源管理器从而由于不活动将设备置于低功率模式。此模式,无论是暂停,无人值守,飞行还是其他,都由OEM定义。请谨慎使用,因为这样做会影响设备的功耗。从用户角度来看,在无人值守模式下进行操作是特别有问题的,因为他们可能认为设备已关闭(看起来像是这样),但现在他们的电池寿命已经降低。


I've recently bought myself a new cellphone, running Windows Mobile 6.1 Professional. And of course I am currently looking into doing some coding for it, on a hobby basis. My plan is to have a service running as a DLL, loaded by Services.exe. This needs to gather som data, and do som processing at regular intervals (every 5-10 minutes).

Since I need to run this at regular intervals, it is a bit of a problem for me, that the system typically goes to sleep (suspend) after a short period of inactivity by the user.

I have been reading all the documentation I could find on MSDN, and MSDN blogs about this subject, and it seems to me, that there are three possible solutions to this problem:

  1. Keep the system in an "Always On"-state, by calling SystemIdleTimerReset periodically. This seems a bit excessive, and is therefore out of the question.

  2. Have the system periodically waken up with CeRunAppAtTime, and enter the unattended state, to do my processing.

  3. Use the unattended state instead of going into a full suspend. This would be transparent to the user, but the system would never go into sleep.

The second approach seems to be preferred, however, this would require an executable to be called by the system on wake up, with the only task of notifying my service that it should commence processing. This seems a bit unnecessary and I would like to avoid this extra executable. I could of course move all my processing into this extra executable, but I would like to use some of the facilities provided when running as a service, and also not have a program pop up (even if its in the background) whenever processing starts.

At first glance, the third approach seems to have the same basic problem as the first. However, I have read on some of the MSDN blogs, that it might be possible to actually conserve battery consumption with this approach, instead of going in and out of suspend mode often (The arguments for this was that the nature of the WM platform is to have a very little battery consumption, when the system is idle. And that going in and out of suspend require quite a bit of processing).

So I guess my questions are as following:

  • Which approach would you recommend in my situation? With respect to keeping a minimum battery consumption, and a nice clean implementation.

  • In the case of approach number two, is it possible to eliminate the need for a notifying executable? Either through alternative API functions, or existing generic applications on the platform?

  • In the case of approach number three, do you know of any information/statistics relevant to the claim, that it is possible to extend the battery lifetime when using unattended mode over going into suspend. E.g. how often do you need to pull the system out of suspend, before unattended mode is to be preferred.

  • Implementation specific (bonus) question: Is it necessary to regularly call SystemIdleTimerReset to stay in unattended mode?

And finally, if you think I have prematurely eliminated approach number one, please tell me why.


Please include in your response whether you base your response on knowledge, or are merely guessing (the latter is also very welcome!).

Please leave a comment, if you think I need to clarify any parts of this question.

解决方案

CERunAppAtTime is a much-misunderstood API (largely because of the terrible name). It doesn't have to run an app. It can simply set a named system event (see the description of the pwszAppName parameter in the MSDN docs). If you care to know when it has fired (to lat your app put the device to sleep again when it's done processing) simply have a worker thread that is doing a WaitForSingleObject on that same named event.

Unattended state is often used for devices that need to keep an app running continuously (like an MP3 player) but conserve power by shutting down the backlight (probably the single most power consuming subsystem).

Obviously unattended mode uses significantly more powr than suspend, becasue in suspend the only power draw is for RAM self-refresh. In unattended mode the processor is stuill powered and running (and several peripherals may be too - depends on how the OEM defined their unattended mode).

SystemIdleTimerReset simply prevents the power manager from putting the device into low-power mode due to inactivity. This mode, whether suspended, unattended, flight or other, is defined by the OEM. Use it sparingly because when your do it impacts the power consumption of the device. Doing it in unattended mode is especially problematic from a user perspective because they might think the device is off (it looks that way) but now their battery life has gone south.

这篇关于在PocketPC上运行后台服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆