General introduction:In Windows Mobile, an API is provided to control background lights. This API enables you to turn on background lights, turn off background lights, and Flash the screen.
Development language:Use the C # language and implement it in the. NET Compact Framework framework.
Applicable scenarios:1. When the system runs for a long time, in order to save the battery of hardware, you can turn off the background light and the software can run in the background. In the 2..net Compact framework, if WebService is used for data interaction, Beijing Light will automatically turn on each WebService call. To avoid this problem, you can turn off the background light before performing data interaction, and turn on the background light after the interaction ends. This is especially suitable for the push technology through thread round robin.
Implementation:
1. encapsulate the devicepowernotify method in the API,CodeAs follows:
[Dllimport ("coredll. dll")]
Private Static extern int devicepowernotify (string device, powerstate devicestate, int deviceflags );
2. encapsulate the powerstate enumeration object
Public Enum powerstate
{
Pwrdeviceunspecified =-1,
Fullon = 0, // full on
Lowon = 1, // low on
Standby = 2, // standby
Sleep = 3, // sleep
Off = 4, // off
Pwrdevicemaximum = 5
};
3. encapsulate an external interface
Public static void setbacklight (powerstate PWR)
{
Devicepowernotify ("bkl1:", PWR, 1 );
}
OK, so far, it has basically been completed. The following describes a method for testing. The effect of the method is that the device based on Windows Mobile flashes the screen.
Int COUNT = 5; // only 5 flashes
While (count> 0)
{
Setbacklight (powerstate. Off );
Thread. Sleep (500 );
Setbacklight (powerstate. Fullon );
Thread. Sleep (500 );
Application. doevents ();
Count --;
}
Have you seen the results? The above code has been tested.